summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mastoapi.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/mastoapi.c b/mastoapi.c
index bd37266..48f32b7 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -669,10 +669,16 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
669 const char *name = xs_dict_get(msg, "name"); 669 const char *name = xs_dict_get(msg, "name");
670 xs *s1 = NULL; 670 xs *s1 = NULL;
671 671
672 if (name) 672 if (name && content)
673 s1 = xs_fmt("%s<br><br>%s", name, content); 673 s1 = xs_fmt("%s<br><br>%s", name, content);
674 else 674 else
675 if (name)
676 s1 = xs_dup(name);
677 else
678 if (content)
675 s1 = xs_dup(content); 679 s1 = xs_dup(content);
680 else
681 s1 = xs_str_new(NULL);
676 682
677 st = xs_dict_append(st, "content", s1); 683 st = xs_dict_append(st, "content", s1);
678 } 684 }
@@ -716,6 +722,22 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
716 if (xs_is_null(mtype)) 722 if (xs_is_null(mtype))
717 mtype = xs_dict_get(aobj, "type"); 723 mtype = xs_dict_get(aobj, "type");
718 724
725 const char *url = xs_dict_get(aobj, "url");
726 if (xs_is_null(url))
727 url = xs_dict_get(aobj, "href");
728 if (xs_is_null(url))
729 continue;
730
731 /* if it's a plain Link, check if it can be "rewritten" */
732 if (xs_list_len(attr_list) < 2 && strcmp(mtype, "Link") == 0) {
733 const char *mt = xs_mime_by_ext(url);
734
735 if (xs_startswith(mt, "image/") ||
736 xs_startswith(mt, "audio/") ||
737 xs_startswith(mt, "video/"))
738 mtype = mt;
739 }
740
719 if (!xs_is_null(mtype)) { 741 if (!xs_is_null(mtype)) {
720 if (xs_startswith(mtype, "image/") || xs_startswith(mtype, "video/") || 742 if (xs_startswith(mtype, "image/") || xs_startswith(mtype, "video/") ||
721 strcmp(mtype, "Image") == 0) { 743 strcmp(mtype, "Image") == 0) {
@@ -724,9 +746,9 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
724 746
725 matte = xs_dict_append(matte, "id", matteid); 747 matte = xs_dict_append(matte, "id", matteid);
726 matte = xs_dict_append(matte, "type", *mtype == 'v' ? "video" : "image"); 748 matte = xs_dict_append(matte, "type", *mtype == 'v' ? "video" : "image");
727 matte = xs_dict_append(matte, "url", xs_dict_get(aobj, "url")); 749 matte = xs_dict_append(matte, "url", url);
728 matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url")); 750 matte = xs_dict_append(matte, "preview_url", url);
729 matte = xs_dict_append(matte, "remote_url", xs_dict_get(aobj, "url")); 751 matte = xs_dict_append(matte, "remote_url", url);
730 752
731 const char *name = xs_dict_get(aobj, "name"); 753 const char *name = xs_dict_get(aobj, "name");
732 if (xs_is_null(name)) 754 if (xs_is_null(name))