summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 8187115..dd80abc 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -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);