aboutsummaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorshtrophic <christoph@liebender.dev>2025-03-20 22:54:56 +0100
committershtrophic <christoph@liebender.dev>2025-03-20 22:54:56 +0100
commit0aeebc177f7f40cd583c65a085c51a9398995135 (patch)
tree7d4c79b675b612ffd16b645f2014dfc9c231c25c /mastoapi.c
parent398b733b2c0ff4c96f4de9731a864373842e86d6 (diff)
parentbd9e9b71d7e039cc2ed971b5f2d54e6553440210 (diff)
Merge tag '2.74' into curl-smtp
Version 2.74 RELEASED.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 1927b0a..8d61681 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -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;
}