diff options
| author | violette <vi@violette.town> | 2026-01-12 06:03:04 +0100 |
|---|---|---|
| committer | grunfink <grunfink@comam.es> | 2026-01-12 06:03:04 +0100 |
| commit | de9d546d70cfcbf3b2450b70039470c9a68ecdc6 (patch) | |
| tree | af3fcc8f82966420a59f0af9b5158d26d93bdb5a /mastoapi.c | |
| parent | 181132331d744065b13e5c6134b39335c51940f5 (diff) | |
Added emoji categories.
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 32 |
1 files changed, 23 insertions, 9 deletions
@@ -2647,19 +2647,33 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/ xs *emo = emojis(); xs *list = xs_list_new(); - int c = 0; const xs_str *k; const xs_val *v; - while(xs_dict_next(emo, &k, &v, &c)) { + xs_dict_foreach(emo, k, v) { xs *current = xs_dict_new(); - if (xs_startswith(v, "https://") && xs_startswith((xs_mime_by_ext(v)), "image/")) { + if ((xs_startswith(v, "https://") && xs_startswith((xs_mime_by_ext(v)), "image/")) || xs_type(v) == XSTYPE_DICT) { /* remove first and last colon */ - xs *shortcode = xs_replace(k, ":", ""); - current = xs_dict_append(current, "shortcode", shortcode); - current = xs_dict_append(current, "url", v); - current = xs_dict_append(current, "static_url", v); - current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE)); - list = xs_list_append(list, current); + if (xs_type(v) == XSTYPE_DICT) { + const char *v2; + const char *cat = k; + xs_dict_foreach(v, k, v2) { + xs *shortcode = xs_replace(k, ":", ""); + current = xs_dict_append(current, "shortcode", shortcode); + current = xs_dict_append(current, "url", v2); + current = xs_dict_append(current, "static_url", v2); + current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE)); + current = xs_dict_append(current, "category", cat); + list = xs_list_append(list, current); + } + } + else { + xs *shortcode = xs_replace(k, ":", ""); + current = xs_dict_append(current, "shortcode", shortcode); + current = xs_dict_append(current, "url", v); + current = xs_dict_append(current, "static_url", v); + current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE)); + list = xs_list_append(list, current); + } } } *body = xs_json_dumps(list, 0); |