summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorGravatar default2023-04-10 13:22:59 +0200
committerGravatar default2023-04-10 13:22:59 +0200
commit9e9d740199e11ca79463f9f4df6f55f0e25cc1aa (patch)
treedcc77be55ee993938c58923960ddc07dcb618593 /mastoapi.c
parentAdded some tweaks for AndStatus, that does some things different (still non-w... (diff)
downloadsnac2-9e9d740199e11ca79463f9f4df6f55f0e25cc1aa.tar.gz
snac2-9e9d740199e11ca79463f9f4df6f55f0e25cc1aa.tar.xz
snac2-9e9d740199e11ca79463f9f4df6f55f0e25cc1aa.zip
Added image attachments.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/mastoapi.c b/mastoapi.c
index bbdcff9..b223ce4 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -622,7 +622,31 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
622 622
623 st = xs_dict_append(st, "spoiler_text", tmp); 623 st = xs_dict_append(st, "spoiler_text", tmp);
624 624
625 st = xs_dict_append(st, "media_attachments", el); 625 /* create the list of attachments */
626 xs *matt = xs_list_new();
627 xs_list *att = xs_dict_get(msg, "attachment");
628 xs_str *aobj;
629
630 while (xs_list_iter(&att, &aobj)) {
631 const char *mtype = xs_dict_get(aobj, "mediaType");
632
633 if (!xs_is_null(mtype) && xs_startswith(mtype, "image/")) {
634 xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt));
635 xs *matte = xs_dict_new();
636
637 matte = xs_dict_append(matte, "id", matteid);
638 matte = xs_dict_append(matte, "type", "image");
639 matte = xs_dict_append(matte, "url", xs_dict_get(aobj, "url"));
640 matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url"));
641 matte = xs_dict_append(matte, "remote_url", xs_dict_get(aobj, "url"));
642 matte = xs_dict_append(matte, "description", xs_dict_get(aobj, "name"));
643
644 matt = xs_list_append(matt, matte);
645 }
646 }
647
648 st = xs_dict_append(st, "media_attachments", matt);
649
626 st = xs_dict_append(st, "mentions", el); 650 st = xs_dict_append(st, "mentions", el);
627 st = xs_dict_append(st, "tags", el); 651 st = xs_dict_append(st, "tags", el);
628 st = xs_dict_append(st, "emojis", el); 652 st = xs_dict_append(st, "emojis", el);