summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-08-17 17:38:39 +0200
committerdefault <nobody@localhost>2023-08-17 17:38:39 +0200
commit6ede6497ad2a63e5ff2b57abba827d0da469f923 (patch)
treea183cf6a66ff73b3a524fdc8955036f58ecea454 /html.c
parentb3b4a4ef61da620d97e1373b16b9844fa6777370 (diff)
Convert 'Link' attachments that have a media extension to something more useful.
Diffstat (limited to 'html.c')
-rw-r--r--html.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/html.c b/html.c
index 8e45eba..e132f17 100644
--- a/html.c
+++ b/html.c
@@ -1313,6 +1313,16 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
if (xs_is_null(url))
continue;
+ /* if it's a plain Link, check if it can be "rewritten" */
+ if (strcmp(t, "Link") == 0) {
+ const char *mt = xs_mime_by_ext(url);
+
+ if (xs_startswith(mt, "image/") ||
+ xs_startswith(mt, "audio/") ||
+ xs_startswith(mt, "video/"))
+ t = mt;
+ }
+
const char *name = xs_dict_get(v, "name");
if (xs_is_null(name))
name = xs_dict_get(msg, "name");