summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorGravatar shtrophic2024-12-23 13:42:45 +0100
committerGravatar shtrophic2024-12-23 13:42:45 +0100
commita7ca4007f2a55a8becab1e4595d2696dd6e7bfd1 (patch)
tree3128196bd7eb298be5a37edac5922009ec5fcac1 /activitypub.c
parentMerge tag '2.66' (diff)
parentVersion 2.67 RELEASED. (diff)
downloadpenes-snac2-a7ca4007f2a55a8becab1e4595d2696dd6e7bfd1.tar.gz
penes-snac2-a7ca4007f2a55a8becab1e4595d2696dd6e7bfd1.tar.xz
penes-snac2-a7ca4007f2a55a8becab1e4595d2696dd6e7bfd1.zip
Merge tag '2.67'
Version 2.67 RELEASED.
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c33
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)
258 d = xs_dict_append(d, "href", href); 258 d = xs_dict_append(d, "href", href);
259 d = xs_dict_append(d, "name", name); 259 d = xs_dict_append(d, "name", name);
260 260
261 const xs_dict *icon = xs_dict_get(v, "icon");
262 if (xs_type(icon) == XSTYPE_DICT)
263 d = xs_dict_append(d, "icon", icon);
264
261 l = xs_list_append(l, d); 265 l = xs_list_append(l, d);
262 } 266 }
263 } 267 }
@@ -1476,20 +1480,31 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
1476 1480
1477 /* create the attachment list, if there are any */ 1481 /* create the attachment list, if there are any */
1478 if (!xs_is_null(attach)) { 1482 if (!xs_is_null(attach)) {
1479 int c = 0; 1483 xs_list_foreach(attach, v) {
1480 while (xs_list_next(attach, &v, &c)) {
1481 xs *d = xs_dict_new();
1482 const char *url = xs_list_get(v, 0); 1484 const char *url = xs_list_get(v, 0);
1483 const char *alt = xs_list_get(v, 1); 1485 const char *alt = xs_list_get(v, 1);
1484 const char *mime = xs_mime_by_ext(url); 1486 const char *mime = xs_mime_by_ext(url);
1487 int add = 1;
1488
1489 /* check if it's already here */
1490 const xs_dict *ad;
1491 xs_list_foreach(atls, ad) {
1492 if (strcmp(xs_dict_get_def(ad, "url", ""), url) == 0) {
1493 add = 0;
1494 break;
1495 }
1496 }
1485 1497
1486 d = xs_dict_append(d, "mediaType", mime); 1498 if (add) {
1487 d = xs_dict_append(d, "url", url); 1499 xs *d = xs_dict_new();
1488 d = xs_dict_append(d, "name", alt); 1500 d = xs_dict_append(d, "mediaType", mime);
1489 d = xs_dict_append(d, "type", 1501 d = xs_dict_append(d, "url", url);
1490 xs_startswith(mime, "image/") ? "Image" : "Document"); 1502 d = xs_dict_append(d, "name", alt);
1503 d = xs_dict_append(d, "type",
1504 xs_startswith(mime, "image/") ? "Image" : "Document");
1491 1505
1492 atls = xs_list_append(atls, d); 1506 atls = xs_list_append(atls, d);
1507 }
1493 } 1508 }
1494 } 1509 }
1495 1510