diff options
| author | shtrophic <christoph@liebender.dev> | 2024-12-23 13:42:45 +0100 |
|---|---|---|
| committer | shtrophic <christoph@liebender.dev> | 2024-12-23 13:42:45 +0100 |
| commit | a7ca4007f2a55a8becab1e4595d2696dd6e7bfd1 (patch) | |
| tree | 3128196bd7eb298be5a37edac5922009ec5fcac1 /activitypub.c | |
| parent | af98f4ed4d0f4f9bebc392eca9dae1eaaa7e77c1 (diff) | |
| parent | 89a8c2e0cc4fcd1f9450dfeb13bf5d83730c52ae (diff) | |
Merge tag '2.67'
Version 2.67 RELEASED.
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/activitypub.c b/activitypub.c index 773df78..34cc32f 100644 --- a/activitypub.c +++ b/activitypub.c @@ -258,6 +258,10 @@ xs_list *get_attachments(const xs_dict *msg) d = xs_dict_append(d, "href", href); d = xs_dict_append(d, "name", name); + const xs_dict *icon = xs_dict_get(v, "icon"); + if (xs_type(icon) == XSTYPE_DICT) + d = xs_dict_append(d, "icon", icon); + l = xs_list_append(l, d); } } @@ -1476,20 +1480,31 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts, /* create the attachment list, if there are any */ if (!xs_is_null(attach)) { - int c = 0; - while (xs_list_next(attach, &v, &c)) { - xs *d = xs_dict_new(); + xs_list_foreach(attach, v) { const char *url = xs_list_get(v, 0); const char *alt = xs_list_get(v, 1); const char *mime = xs_mime_by_ext(url); + int add = 1; + + /* check if it's already here */ + const xs_dict *ad; + xs_list_foreach(atls, ad) { + if (strcmp(xs_dict_get_def(ad, "url", ""), url) == 0) { + add = 0; + break; + } + } - d = xs_dict_append(d, "mediaType", mime); - d = xs_dict_append(d, "url", url); - d = xs_dict_append(d, "name", alt); - d = xs_dict_append(d, "type", - xs_startswith(mime, "image/") ? "Image" : "Document"); + if (add) { + xs *d = xs_dict_new(); + d = xs_dict_append(d, "mediaType", mime); + d = xs_dict_append(d, "url", url); + d = xs_dict_append(d, "name", alt); + d = xs_dict_append(d, "type", + xs_startswith(mime, "image/") ? "Image" : "Document"); - atls = xs_list_append(atls, d); + atls = xs_list_append(atls, d); + } } } |