commit f136426
default
·
2023-05-21 18:12:59 +0000 UTC
parent 63053ab
Minor refactor to msg_note().
1 files changed,
+3,
-5
+3,
-5
1@@ -772,7 +772,7 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
2 xs *cc = xs_list_new();
3 xs *irt = NULL;
4 xs *tag = xs_list_new();
5- xs *atls = NULL;
6+ xs *atls = xs_list_new();
7 xs_dict *msg = msg_base(snac, "Note", id, NULL, "@now", NULL);
8 xs_list *p;
9 xs_val *v;
10@@ -838,10 +838,8 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
11
12 /* create the attachment list, if there are any */
13 if (!xs_is_null(attach)) {
14- atls = xs_list_new();
15-
16 while (xs_list_iter(&attach, &v)) {
17- xs *d = xs_dict_new();
18+ xs *d = xs_dict_new();
19 char *url = xs_list_get(v, 0);
20 char *alt = xs_list_get(v, 1);
21 char *mime = xs_mime_by_ext(url);
22@@ -897,7 +895,7 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
23
24 msg = xs_dict_append(msg, "sourceContent", content);
25
26- if (atls != NULL)
27+ if (xs_list_len(atls))
28 msg = xs_dict_append(msg, "attachment", atls);
29
30 return msg;