commit 05d6e41

default  ·  2024-12-21 16:06:01 +0000 UTC
parent 5ffd443
If an attachment includes an icon, show it.
2 files changed,  +21, -0
M html.c
+4, -0
 1@@ -258,6 +258,10 @@ xs_list *get_attachments(const xs_dict *msg)
 2             d = xs_dict_append(d, "href", href);
 3             d = xs_dict_append(d, "name", name);
 4 
 5+            const xs_dict *icon = xs_dict_get(v, "icon");
 6+            if (xs_type(icon) == XSTYPE_DICT)
 7+                d = xs_dict_append(d, "icon", icon);
 8+
 9             l = xs_list_append(l, d);
10         }
11     }
M html.c
+17, -0
 1@@ -2061,6 +2061,23 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
 2             if (content && xs_str_in(content, o_href) != -1)
 3                 continue;
 4 
 5+            /* do this attachment include an icon? */
 6+            const xs_dict *icon = xs_dict_get(a, "icon");
 7+            if (xs_type(icon) == XSTYPE_DICT) {
 8+                const char *icon_mtype = xs_dict_get(icon, "mediaType");
 9+                const char *icon_url   = xs_dict_get(icon, "url");
10+
11+                if (icon_mtype && icon_url && xs_startswith(icon_mtype, "image/")) {
12+                    xs_html_add(content_attachments,
13+                        xs_html_tag("a",
14+                            xs_html_attr("href", icon_url),
15+                            xs_html_attr("target", "_blank"),
16+                            xs_html_sctag("img",
17+                                xs_html_attr("loading", "lazy"),
18+                                xs_html_attr("src", icon_url))));
19+                }
20+            }
21+
22             xs *href = make_url(o_href, proxy, 0);
23 
24             if (xs_startswith(type, "image/") || strcmp(type, "Image") == 0) {