diff options
| author | 2023-08-17 17:38:39 +0200 | |
|---|---|---|
| committer | 2023-08-17 17:38:39 +0200 | |
| commit | 6ede6497ad2a63e5ff2b57abba827d0da469f923 (patch) | |
| tree | a183cf6a66ff73b3a524fdc8955036f58ecea454 /html.c | |
| parent | Return the history in reverse order, which has more sense. (diff) | |
| download | snac2-6ede6497ad2a63e5ff2b57abba827d0da469f923.tar.gz snac2-6ede6497ad2a63e5ff2b57abba827d0da469f923.tar.xz snac2-6ede6497ad2a63e5ff2b57abba827d0da469f923.zip | |
Convert 'Link' attachments that have a media extension to something more useful.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 10 |
1 files changed, 10 insertions, 0 deletions
| @@ -1313,6 +1313,16 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, | |||
| 1313 | if (xs_is_null(url)) | 1313 | if (xs_is_null(url)) |
| 1314 | continue; | 1314 | continue; |
| 1315 | 1315 | ||
| 1316 | /* if it's a plain Link, check if it can be "rewritten" */ | ||
| 1317 | if (strcmp(t, "Link") == 0) { | ||
| 1318 | const char *mt = xs_mime_by_ext(url); | ||
| 1319 | |||
| 1320 | if (xs_startswith(mt, "image/") || | ||
| 1321 | xs_startswith(mt, "audio/") || | ||
| 1322 | xs_startswith(mt, "video/")) | ||
| 1323 | t = mt; | ||
| 1324 | } | ||
| 1325 | |||
| 1316 | const char *name = xs_dict_get(v, "name"); | 1326 | const char *name = xs_dict_get(v, "name"); |
| 1317 | if (xs_is_null(name)) | 1327 | if (xs_is_null(name)) |
| 1318 | name = xs_dict_get(msg, "name"); | 1328 | name = xs_dict_get(msg, "name"); |