mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-26 17:23:38 +00:00
If an attachment includes an icon, show it.
This commit is contained in:
parent
5ffd4435d8
commit
05d6e41710
2 changed files with 21 additions and 0 deletions
|
@ -258,6 +258,10 @@ xs_list *get_attachments(const xs_dict *msg)
|
||||||
d = xs_dict_append(d, "href", href);
|
d = xs_dict_append(d, "href", href);
|
||||||
d = xs_dict_append(d, "name", name);
|
d = xs_dict_append(d, "name", name);
|
||||||
|
|
||||||
|
const xs_dict *icon = xs_dict_get(v, "icon");
|
||||||
|
if (xs_type(icon) == XSTYPE_DICT)
|
||||||
|
d = xs_dict_append(d, "icon", icon);
|
||||||
|
|
||||||
l = xs_list_append(l, d);
|
l = xs_list_append(l, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
17
html.c
17
html.c
|
@ -2061,6 +2061,23 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
|
||||||
if (content && xs_str_in(content, o_href) != -1)
|
if (content && xs_str_in(content, o_href) != -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* do this attachment include an icon? */
|
||||||
|
const xs_dict *icon = xs_dict_get(a, "icon");
|
||||||
|
if (xs_type(icon) == XSTYPE_DICT) {
|
||||||
|
const char *icon_mtype = xs_dict_get(icon, "mediaType");
|
||||||
|
const char *icon_url = xs_dict_get(icon, "url");
|
||||||
|
|
||||||
|
if (icon_mtype && icon_url && xs_startswith(icon_mtype, "image/")) {
|
||||||
|
xs_html_add(content_attachments,
|
||||||
|
xs_html_tag("a",
|
||||||
|
xs_html_attr("href", icon_url),
|
||||||
|
xs_html_attr("target", "_blank"),
|
||||||
|
xs_html_sctag("img",
|
||||||
|
xs_html_attr("loading", "lazy"),
|
||||||
|
xs_html_attr("src", icon_url))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xs *href = make_url(o_href, proxy, 0);
|
xs *href = make_url(o_href, proxy, 0);
|
||||||
|
|
||||||
if (xs_startswith(type, "image/") || strcmp(type, "Image") == 0) {
|
if (xs_startswith(type, "image/") || strcmp(type, "Image") == 0) {
|
||||||
|
|
Loading…
Reference in a new issue