diff --git a/mastoapi.c b/mastoapi.c index b7f45f4..bd37266 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -12,6 +12,7 @@ #include "xs_set.h" #include "xs_random.h" #include "xs_httpd.h" +#include "xs_mime.h" #include "snac.h" @@ -1524,11 +1525,32 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, xs *d13 = xs_json_loads("{\"image_matrix_limit\":33177600," "\"image_size_limit\":16777216," - "\"supported_mime_types\":[\"image/jpeg\"]," "\"video_frame_rate_limit\":120," "\"video_matrix_limit\":8294400," "\"video_size_limit\":103809024}" ); + + { + /* get the supported mime types from the internal list */ + const char **p = xs_mime_types; + xs_set mtypes; + xs_set_init(&mtypes); + + while (*p) { + const char *type = p[1]; + + if (xs_startswith(type, "image/") || + xs_startswith(type, "video/") || + xs_startswith(type, "audio/")) + xs_set_add(&mtypes, type); + + p += 2; + } + + xs *l = xs_set_result(&mtypes); + d13 = xs_dict_append(d13, "supported_mime_types", l); + } + cfg = xs_dict_append(cfg, "media_attachments", d13); 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) const char **p = xs_mime_types; xs *uext = xs_tolower_i(xs_dup(ext + 1)); - while (**p) { + while (*p) { int c; 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 */