|
@@ -2647,19 +2647,33 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|
|
if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/
|
|
if (strcmp(cmd, "/v1/custom_emojis") == 0) { /** **/
|
|
|
xs *emo = emojis();
|
|
xs *emo = emojis();
|
|
|
xs *list = xs_list_new();
|
|
xs *list = xs_list_new();
|
|
|
- int c = 0;
|
|
|
|
|
const xs_str *k;
|
|
const xs_str *k;
|
|
|
const xs_val *v;
|
|
const xs_val *v;
|
|
|
- while(xs_dict_next(emo, &k, &v, &c)) {
|
|
|
|
|
|
|
+ xs_dict_foreach(emo, k, v) {
|
|
|
xs *current = xs_dict_new();
|
|
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 */
|
|
/* 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);
|
|
*body = xs_json_dumps(list, 0);
|