mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
mastoapi: in instance, return the list of supported mime types from the internal list.
This commit is contained in:
parent
6ede6497ad
commit
93bdf79eb6
3 changed files with 25 additions and 3 deletions
24
mastoapi.c
24
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,"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1 +1 @@
|
|||
/* e85f257dd8fcb2980fd21aa37c1594c1461ddf48 */
|
||||
/* ca82377df89097bd3965875fd63286d6c7af26eb */
|
||||
|
|
Loading…
Reference in a new issue