summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-08-17 18:06:36 +0200
committerGravatar default2023-08-17 18:06:36 +0200
commit93bdf79eb69d79803a091e2d6583772b40e41f44 (patch)
treeb4cc7299ada89eb008ea287de3afd0a1ae128a30
parentConvert 'Link' attachments that have a media extension to something more useful. (diff)
downloadsnac2-93bdf79eb69d79803a091e2d6583772b40e41f44.tar.gz
snac2-93bdf79eb69d79803a091e2d6583772b40e41f44.tar.xz
snac2-93bdf79eb69d79803a091e2d6583772b40e41f44.zip
mastoapi: in instance, return the list of supported mime types from the internal list.
-rw-r--r--mastoapi.c24
-rw-r--r--xs_mime.h2
-rw-r--r--xs_version.h2
3 files changed, 25 insertions, 3 deletions
diff --git a/mastoapi.c b/mastoapi.c
index b7f45f4..bd37266 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -12,6 +12,7 @@
12#include "xs_set.h" 12#include "xs_set.h"
13#include "xs_random.h" 13#include "xs_random.h"
14#include "xs_httpd.h" 14#include "xs_httpd.h"
15#include "xs_mime.h"
15 16
16#include "snac.h" 17#include "snac.h"
17 18
@@ -1524,11 +1525,32 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1524 1525
1525 xs *d13 = xs_json_loads("{\"image_matrix_limit\":33177600," 1526 xs *d13 = xs_json_loads("{\"image_matrix_limit\":33177600,"
1526 "\"image_size_limit\":16777216," 1527 "\"image_size_limit\":16777216,"
1527 "\"supported_mime_types\":[\"image/jpeg\"],"
1528 "\"video_frame_rate_limit\":120," 1528 "\"video_frame_rate_limit\":120,"
1529 "\"video_matrix_limit\":8294400," 1529 "\"video_matrix_limit\":8294400,"
1530 "\"video_size_limit\":103809024}" 1530 "\"video_size_limit\":103809024}"
1531 ); 1531 );
1532
1533 {
1534 /* get the supported mime types from the internal list */
1535 const char **p = xs_mime_types;
1536 xs_set mtypes;
1537 xs_set_init(&mtypes);
1538
1539 while (*p) {
1540 const char *type = p[1];
1541
1542 if (xs_startswith(type, "image/") ||
1543 xs_startswith(type, "video/") ||
1544 xs_startswith(type, "audio/"))
1545 xs_set_add(&mtypes, type);
1546
1547 p += 2;
1548 }
1549
1550 xs *l = xs_set_result(&mtypes);
1551 d13 = xs_dict_append(d13, "supported_mime_types", l);
1552 }
1553
1532 cfg = xs_dict_append(cfg, "media_attachments", d13); 1554 cfg = xs_dict_append(cfg, "media_attachments", d13);
1533 1555
1534 xs *d14 = xs_json_loads("{\"max_characters_per_option\":50," 1556 xs *d14 = xs_json_loads("{\"max_characters_per_option\":50,"
diff --git a/xs_mime.h b/xs_mime.h
index 2c8eaa9..cab341c 100644
--- a/xs_mime.h
+++ b/xs_mime.h
@@ -56,7 +56,7 @@ const char *xs_mime_by_ext(const char *file)
56 const char **p = xs_mime_types; 56 const char **p = xs_mime_types;
57 xs *uext = xs_tolower_i(xs_dup(ext + 1)); 57 xs *uext = xs_tolower_i(xs_dup(ext + 1));
58 58
59 while (**p) { 59 while (*p) {
60 int c; 60 int c;
61 61
62 if ((c = strcmp(*p, uext)) == 0) 62 if ((c = strcmp(*p, uext)) == 0)
diff --git a/xs_version.h b/xs_version.h
index 8b2dea3..ab26d46 100644
--- a/xs_version.h
+++ b/xs_version.h
@@ -1 +1 @@
/* e85f257dd8fcb2980fd21aa37c1594c1461ddf48 */ /* ca82377df89097bd3965875fd63286d6c7af26eb */