summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/mastoapi.c b/mastoapi.c
index e7d9b60..73b4d9f 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -662,7 +662,19 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
662 st = xs_dict_append(st, "url", id); 662 st = xs_dict_append(st, "url", id);
663 st = xs_dict_append(st, "created_at", xs_dict_get(msg, "published")); 663 st = xs_dict_append(st, "created_at", xs_dict_get(msg, "published"));
664 st = xs_dict_append(st, "account", acct); 664 st = xs_dict_append(st, "account", acct);
665 st = xs_dict_append(st, "content", xs_dict_get(msg, "content")); 665
666 {
667 const char *content = xs_dict_get(msg, "content");
668 const char *name = xs_dict_get(msg, "name");
669 xs *s1 = NULL;
670
671 if (name)
672 s1 = xs_fmt("%s<br><br>%s", name, content);
673 else
674 s1 = xs_dup(content);
675
676 st = xs_dict_append(st, "content", s1);
677 }
666 678
667 st = xs_dict_append(st, "visibility", 679 st = xs_dict_append(st, "visibility",
668 is_msg_public(msg) ? "public" : "private"); 680 is_msg_public(msg) ? "public" : "private");
@@ -683,17 +695,34 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
683 xs *matt = xs_list_new(); 695 xs *matt = xs_list_new();
684 xs_list *att = xs_dict_get(msg, "attachment"); 696 xs_list *att = xs_dict_get(msg, "attachment");
685 xs_str *aobj; 697 xs_str *aobj;
698 xs *attr_list = NULL;
699
700 if (xs_type(att) == XSTYPE_DICT) {
701 attr_list = xs_list_new();
702 attr_list = xs_list_append(attr_list, att);
703 }
704 else
705 attr_list = xs_dup(att);
706
707 /* if it has an image, add it as an attachment */
708 xs_dict *image = xs_dict_get(msg, "image");
709 if (!xs_is_null(image))
710 attr_list = xs_list_append(attr_list, image);
686 711
712 att = attr_list;
687 while (xs_list_iter(&att, &aobj)) { 713 while (xs_list_iter(&att, &aobj)) {
688 const char *mtype = xs_dict_get(aobj, "mediaType"); 714 const char *mtype = xs_dict_get(aobj, "mediaType");
715 if (xs_is_null(mtype))
716 mtype = xs_dict_get(aobj, "type");
689 717
690 if (!xs_is_null(mtype)) { 718 if (!xs_is_null(mtype)) {
691 if (xs_startswith(mtype, "image/") || xs_startswith(mtype, "video/")) { 719 if (xs_startswith(mtype, "image/") || xs_startswith(mtype, "video/") ||
720 strcmp(mtype, "Image") == 0) {
692 xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt)); 721 xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt));
693 xs *matte = xs_dict_new(); 722 xs *matte = xs_dict_new();
694 723
695 matte = xs_dict_append(matte, "id", matteid); 724 matte = xs_dict_append(matte, "id", matteid);
696 matte = xs_dict_append(matte, "type", *mtype == 'i' ? "image" : "video"); 725 matte = xs_dict_append(matte, "type", *mtype == 'v' ? "video" : "image");
697 matte = xs_dict_append(matte, "url", xs_dict_get(aobj, "url")); 726 matte = xs_dict_append(matte, "url", xs_dict_get(aobj, "url"));
698 matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url")); 727 matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url"));
699 matte = xs_dict_append(matte, "remote_url", xs_dict_get(aobj, "url")); 728 matte = xs_dict_append(matte, "remote_url", xs_dict_get(aobj, "url"));