mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
Added image attachments.
This commit is contained in:
parent
3fb651b7b1
commit
9e9d740199
2 changed files with 31 additions and 4 deletions
9
html.c
9
html.c
|
@ -332,7 +332,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
|
|||
"<input type=\"hidden\" name=\"in_reply_to\" value=\"\">\n"
|
||||
"<p>%s: <input type=\"checkbox\" name=\"sensitive\">\n"
|
||||
"<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n"
|
||||
"<p><input type=\"file\" name=\"attach\">\n"
|
||||
"<p>%s: <input type=\"file\" name=\"attach\">\n"
|
||||
"<p>%s: <input type=\"text\" name=\"alt_text\">\n"
|
||||
"<p><input type=\"submit\" class=\"button\" value=\"%s\">\n"
|
||||
"</form><p>\n"
|
||||
|
@ -425,6 +425,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
|
|||
snac->actor,
|
||||
L("Sensitive content"),
|
||||
L("Only for mentioned people"),
|
||||
L("Image"),
|
||||
L("Image description"),
|
||||
L("Post"),
|
||||
|
||||
|
@ -593,7 +594,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, const char *md5)
|
|||
|
||||
"<p>%s: <input type=\"checkbox\" name=\"sensitive\">\n"
|
||||
"<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n"
|
||||
"<p><input type=\"file\" name=\"attach\">\n"
|
||||
"<p>%s: <input type=\"file\" name=\"attach\">\n"
|
||||
"<p>%s: <input type=\"text\" name=\"alt_text\">\n"
|
||||
|
||||
"<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)
|
|||
id,
|
||||
L("Sensitive content"),
|
||||
L("Only for mentioned people"),
|
||||
L("Image"),
|
||||
L("Image description"),
|
||||
md5,
|
||||
L("Post")
|
||||
|
@ -632,7 +634,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, const char *md5)
|
|||
|
||||
"<p>%s: <input type=\"checkbox\" name=\"sensitive\">\n"
|
||||
"<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n"
|
||||
"<p><input type=\"file\" name=\"attach\">\n"
|
||||
"<p>%s: <input type=\"file\" name=\"attach\">\n"
|
||||
"<p>%s: <input type=\"text\" name=\"alt_text\">\n"
|
||||
|
||||
"<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)
|
|||
id,
|
||||
L("Sensitive content"),
|
||||
L("Only for mentioned people"),
|
||||
L("Image"),
|
||||
L("Image description"),
|
||||
md5,
|
||||
L("Post")
|
||||
|
|
26
mastoapi.c
26
mastoapi.c
|
@ -622,7 +622,31 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
|
||||
st = xs_dict_append(st, "spoiler_text", tmp);
|
||||
|
||||
st = xs_dict_append(st, "media_attachments", el);
|
||||
/* create the list of attachments */
|
||||
xs *matt = xs_list_new();
|
||||
xs_list *att = xs_dict_get(msg, "attachment");
|
||||
xs_str *aobj;
|
||||
|
||||
while (xs_list_iter(&att, &aobj)) {
|
||||
const char *mtype = xs_dict_get(aobj, "mediaType");
|
||||
|
||||
if (!xs_is_null(mtype) && xs_startswith(mtype, "image/")) {
|
||||
xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt));
|
||||
xs *matte = xs_dict_new();
|
||||
|
||||
matte = xs_dict_append(matte, "id", matteid);
|
||||
matte = xs_dict_append(matte, "type", "image");
|
||||
matte = xs_dict_append(matte, "url", xs_dict_get(aobj, "url"));
|
||||
matte = xs_dict_append(matte, "preview_url", xs_dict_get(aobj, "url"));
|
||||
matte = xs_dict_append(matte, "remote_url", xs_dict_get(aobj, "url"));
|
||||
matte = xs_dict_append(matte, "description", xs_dict_get(aobj, "name"));
|
||||
|
||||
matt = xs_list_append(matt, matte);
|
||||
}
|
||||
}
|
||||
|
||||
st = xs_dict_append(st, "media_attachments", matt);
|
||||
|
||||
st = xs_dict_append(st, "mentions", el);
|
||||
st = xs_dict_append(st, "tags", el);
|
||||
st = xs_dict_append(st, "emojis", el);
|
||||
|
|
Loading…
Reference in a new issue