diff options
| author | 2025-03-21 17:14:58 +0000 | |
|---|---|---|
| committer | 2025-03-21 17:14:58 +0000 | |
| commit | 83c8218f71a7d901609f10df6612bf457c30f35a (patch) | |
| tree | a08b014ced2dd68b20e498195d4c2c6064225dab /mastoapi.c | |
| parent | Merge pull request 'refresh master' (#3) from grunfink/snac2:master into master (diff) | |
| parent | Merge pull request 'added missing czech translations' (#332) from pmjv/snac2:... (diff) | |
| download | snac2-83c8218f71a7d901609f10df6612bf457c30f35a.tar.gz snac2-83c8218f71a7d901609f10df6612bf457c30f35a.tar.xz snac2-83c8218f71a7d901609f10df6612bf457c30f35a.zip | |
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, | |||
| 2116 | } | 2116 | } |
| 2117 | else | 2117 | else |
| 2118 | if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/ | 2118 | if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/ |
| 2119 | /* are you kidding me? */ | 2119 | xs *emo = emojis(); |
| 2120 | *body = xs_dup("[]"); | 2120 | xs *list = xs_list_new(); |
| 2121 | int c = 0; | ||
| 2122 | const xs_str *k; | ||
| 2123 | const xs_val *v; | ||
| 2124 | while(xs_dict_next(emo, &k, &v, &c)) { | ||
| 2125 | xs *current = xs_dict_new(); | ||
| 2126 | if (xs_startswith(v, "https://") && xs_startswith((xs_mime_by_ext(v)), "image/")) { | ||
| 2127 | /* remove first and last colon */ | ||
| 2128 | xs *shortcode = xs_replace(k, ":", ""); | ||
| 2129 | current = xs_dict_append(current, "shortcode", shortcode); | ||
| 2130 | current = xs_dict_append(current, "url", v); | ||
| 2131 | current = xs_dict_append(current, "static_url", v); | ||
| 2132 | current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE)); | ||
| 2133 | list = xs_list_append(list, current); | ||
| 2134 | } | ||
| 2135 | } | ||
| 2136 | *body = xs_json_dumps(list, 0); | ||
| 2121 | *ctype = "application/json"; | 2137 | *ctype = "application/json"; |
| 2122 | status = HTTP_STATUS_OK; | 2138 | status = HTTP_STATUS_OK; |
| 2123 | } | 2139 | } |