diff options
| author | 2023-04-10 13:22:59 +0200 | |
|---|---|---|
| committer | 2023-04-10 13:22:59 +0200 | |
| commit | 9e9d740199e11ca79463f9f4df6f55f0e25cc1aa (patch) | |
| tree | dcc77be55ee993938c58923960ddc07dcb618593 /mastoapi.c | |
| parent | Added some tweaks for AndStatus, that does some things different (still non-w... (diff) | |
| download | snac2-9e9d740199e11ca79463f9f4df6f55f0e25cc1aa.tar.gz snac2-9e9d740199e11ca79463f9f4df6f55f0e25cc1aa.tar.xz snac2-9e9d740199e11ca79463f9f4df6f55f0e25cc1aa.zip | |
Added image attachments.
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 26 |
1 files changed, 25 insertions, 1 deletions
| @@ -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); |