summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-04-10 13:22:59 +0200
committerGravatar default2023-04-10 13:22:59 +0200
commit9e9d740199e11ca79463f9f4df6f55f0e25cc1aa (patch)
treedcc77be55ee993938c58923960ddc07dcb618593
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.
-rw-r--r--html.c9
-rw-r--r--mastoapi.c26
2 files changed, 31 insertions, 4 deletions
diff --git a/html.c b/html.c
index 9850dfd..c8d3e39 100644
--- a/html.c
+++ b/html.c
@@ -332,7 +332,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
332 "<input type=\"hidden\" name=\"in_reply_to\" value=\"\">\n" 332 "<input type=\"hidden\" name=\"in_reply_to\" value=\"\">\n"
333 "<p>%s: <input type=\"checkbox\" name=\"sensitive\">\n" 333 "<p>%s: <input type=\"checkbox\" name=\"sensitive\">\n"
334 "<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n" 334 "<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n"
335 "<p><input type=\"file\" name=\"attach\">\n" 335 "<p>%s: <input type=\"file\" name=\"attach\">\n"
336 "<p>%s: <input type=\"text\" name=\"alt_text\">\n" 336 "<p>%s: <input type=\"text\" name=\"alt_text\">\n"
337 "<p><input type=\"submit\" class=\"button\" value=\"%s\">\n" 337 "<p><input type=\"submit\" class=\"button\" value=\"%s\">\n"
338 "</form><p>\n" 338 "</form><p>\n"
@@ -425,6 +425,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
425 snac->actor, 425 snac->actor,
426 L("Sensitive content"), 426 L("Sensitive content"),
427 L("Only for mentioned people"), 427 L("Only for mentioned people"),
428 L("Image"),
428 L("Image description"), 429 L("Image description"),
429 L("Post"), 430 L("Post"),
430 431
@@ -593,7 +594,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, const char *md5)
593 594
594 "<p>%s: <input type=\"checkbox\" name=\"sensitive\">\n" 595 "<p>%s: <input type=\"checkbox\" name=\"sensitive\">\n"
595 "<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n" 596 "<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n"
596 "<p><input type=\"file\" name=\"attach\">\n" 597 "<p>%s: <input type=\"file\" name=\"attach\">\n"
597 "<p>%s: <input type=\"text\" name=\"alt_text\">\n" 598 "<p>%s: <input type=\"text\" name=\"alt_text\">\n"
598 599
599 "<input type=\"hidden\" name=\"redir\" value=\"%s_entry\">\n" 600 "<input type=\"hidden\" name=\"redir\" value=\"%s_entry\">\n"
@@ -609,6 +610,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, const char *md5)
609 id, 610 id,
610 L("Sensitive content"), 611 L("Sensitive content"),
611 L("Only for mentioned people"), 612 L("Only for mentioned people"),
613 L("Image"),
612 L("Image description"), 614 L("Image description"),
613 md5, 615 md5,
614 L("Post") 616 L("Post")
@@ -632,7 +634,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, const char *md5)
632 634
633 "<p>%s: <input type=\"checkbox\" name=\"sensitive\">\n" 635 "<p>%s: <input type=\"checkbox\" name=\"sensitive\">\n"
634 "<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n" 636 "<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n"
635 "<p><input type=\"file\" name=\"attach\">\n" 637 "<p>%s: <input type=\"file\" name=\"attach\">\n"
636 "<p>%s: <input type=\"text\" name=\"alt_text\">\n" 638 "<p>%s: <input type=\"text\" name=\"alt_text\">\n"
637 639
638 "<input type=\"hidden\" name=\"redir\" value=\"%s_entry\">\n" 640 "<input type=\"hidden\" name=\"redir\" value=\"%s_entry\">\n"
@@ -648,6 +650,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, const char *md5)
648 id, 650 id,
649 L("Sensitive content"), 651 L("Sensitive content"),
650 L("Only for mentioned people"), 652 L("Only for mentioned people"),
653 L("Image"),
651 L("Image description"), 654 L("Image description"),
652 md5, 655 md5,
653 L("Post") 656 L("Post")
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);