commit 93bdf79
default
·
2023-08-17 16:06:36 +0000 UTC
parent 6ede649
mastoapi: in instance, return the list of supported mime types from the internal list.
3 files changed,
+25,
-3
+23,
-1
1@@ -12,6 +12,7 @@
2 #include "xs_set.h"
3 #include "xs_random.h"
4 #include "xs_httpd.h"
5+#include "xs_mime.h"
6
7 #include "snac.h"
8
9@@ -1524,11 +1525,32 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
10
11 xs *d13 = xs_json_loads("{\"image_matrix_limit\":33177600,"
12 "\"image_size_limit\":16777216,"
13- "\"supported_mime_types\":[\"image/jpeg\"],"
14 "\"video_frame_rate_limit\":120,"
15 "\"video_matrix_limit\":8294400,"
16 "\"video_size_limit\":103809024}"
17 );
18+
19+ {
20+ /* get the supported mime types from the internal list */
21+ const char **p = xs_mime_types;
22+ xs_set mtypes;
23+ xs_set_init(&mtypes);
24+
25+ while (*p) {
26+ const char *type = p[1];
27+
28+ if (xs_startswith(type, "image/") ||
29+ xs_startswith(type, "video/") ||
30+ xs_startswith(type, "audio/"))
31+ xs_set_add(&mtypes, type);
32+
33+ p += 2;
34+ }
35+
36+ xs *l = xs_set_result(&mtypes);
37+ d13 = xs_dict_append(d13, "supported_mime_types", l);
38+ }
39+
40 cfg = xs_dict_append(cfg, "media_attachments", d13);
41
42 xs *d14 = xs_json_loads("{\"max_characters_per_option\":50,"
+1,
-1
1@@ -56,7 +56,7 @@ const char *xs_mime_by_ext(const char *file)
2 const char **p = xs_mime_types;
3 xs *uext = xs_tolower_i(xs_dup(ext + 1));
4
5- while (**p) {
6+ while (*p) {
7 int c;
8
9 if ((c = strcmp(*p, uext)) == 0)
+1,
-1
1@@ -1 +1 @@
2-/* e85f257dd8fcb2980fd21aa37c1594c1461ddf48 */
3+/* ca82377df89097bd3965875fd63286d6c7af26eb */