diff options
| author | 2026-01-12 06:03:04 +0100 | |
|---|---|---|
| committer | 2026-01-12 06:03:04 +0100 | |
| commit | de9d546d70cfcbf3b2450b70039470c9a68ecdc6 (patch) | |
| tree | af3fcc8f82966420a59f0af9b5158d26d93bdb5a /mastoapi.c | |
| parent | Updated documentation. (diff) | |
| download | snac2-de9d546d70cfcbf3b2450b70039470c9a68ecdc6.tar.gz snac2-de9d546d70cfcbf3b2450b70039470c9a68ecdc6.tar.xz snac2-de9d546d70cfcbf3b2450b70039470c9a68ecdc6.zip | |
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, | |||
| 2647 | if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/ | 2647 | if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/ |
| 2648 | xs *emo = emojis(); | 2648 | xs *emo = emojis(); |
| 2649 | xs *list = xs_list_new(); | 2649 | xs *list = xs_list_new(); |
| 2650 | int c = 0; | ||
| 2651 | const xs_str *k; | 2650 | const xs_str *k; |
| 2652 | const xs_val *v; | 2651 | const xs_val *v; |
| 2653 | while(xs_dict_next(emo, &k, &v, &c)) { | 2652 | xs_dict_foreach(emo, k, v) { |
| 2654 | xs *current = xs_dict_new(); | 2653 | xs *current = xs_dict_new(); |
| 2655 | if (xs_startswith(v, "https://") && xs_startswith((xs_mime_by_ext(v)), "image/")) { | 2654 | if ((xs_startswith(v, "https://") && xs_startswith((xs_mime_by_ext(v)), "image/")) || xs_type(v) == XSTYPE_DICT) { |
| 2656 | /* remove first and last colon */ | 2655 | /* remove first and last colon */ |
| 2657 | xs *shortcode = xs_replace(k, ":", ""); | 2656 | if (xs_type(v) == XSTYPE_DICT) { |
| 2658 | current = xs_dict_append(current, "shortcode", shortcode); | 2657 | const char *v2; |
| 2659 | current = xs_dict_append(current, "url", v); | 2658 | const char *cat = k; |
| 2660 | current = xs_dict_append(current, "static_url", v); | 2659 | xs_dict_foreach(v, k, v2) { |
| 2661 | current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE)); | 2660 | xs *shortcode = xs_replace(k, ":", ""); |
| 2662 | list = xs_list_append(list, current); | 2661 | current = xs_dict_append(current, "shortcode", shortcode); |
| 2662 | current = xs_dict_append(current, "url", v2); | ||
| 2663 | current = xs_dict_append(current, "static_url", v2); | ||
| 2664 | current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE)); | ||
| 2665 | current = xs_dict_append(current, "category", cat); | ||
| 2666 | list = xs_list_append(list, current); | ||
| 2667 | } | ||
| 2668 | } | ||
| 2669 | else { | ||
| 2670 | xs *shortcode = xs_replace(k, ":", ""); | ||
| 2671 | current = xs_dict_append(current, "shortcode", shortcode); | ||
| 2672 | current = xs_dict_append(current, "url", v); | ||
| 2673 | current = xs_dict_append(current, "static_url", v); | ||
| 2674 | current = xs_dict_append(current, "visible_in_picker", xs_stock(XSTYPE_TRUE)); | ||
| 2675 | list = xs_list_append(list, current); | ||
| 2676 | } | ||
| 2663 | } | 2677 | } |
| 2664 | } | 2678 | } |
| 2665 | *body = xs_json_dumps(list, 0); | 2679 | *body = xs_json_dumps(list, 0); |