diff options
| author | Oliver <zen@noreply.codeberg.org> | 2025-03-21 17:14:58 +0000 |
|---|---|---|
| committer | Oliver <zen@noreply.codeberg.org> | 2025-03-21 17:14:58 +0000 |
| commit | 83c8218f71a7d901609f10df6612bf457c30f35a (patch) | |
| tree | a08b014ced2dd68b20e498195d4c2c6064225dab /mastoapi.c | |
| parent | c9a6cb8bb0047a1976e390bb1f3e09e58d70b9f5 (diff) | |
| parent | d68d2f51df95dde970fbc8972c49276c52d5a7d6 (diff) | |
Merge pull request 'v2.74' (#4) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/zen/snac2/pulls/4
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -2116,8 +2116,24 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, } else if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/ - /* are you kidding me? */ - *body = xs_dup("[]"); + 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 *current = xs_dict_new(); + if (xs_startswith(v, "https://") && xs_startswith((xs_mime_by_ext(v)), "image/")) { + /* 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); + } + } + *body = xs_json_dumps(list, 0); *ctype = "application/json"; status = HTTP_STATUS_OK; } |