summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar grunfink2025-06-16 05:11:33 +0200
committerGravatar grunfink2025-06-16 05:11:33 +0200
commitf8055ccfb52c5fdf9c08b608060409625982cd05 (patch)
tree514ffceaa5e4fab6592ae18ea7235c8a82a0b8cc
parentUpdated RELEASE_NOTES. (diff)
downloadpenes-snac2-f8055ccfb52c5fdf9c08b608060409625982cd05.tar.gz
penes-snac2-f8055ccfb52c5fdf9c08b608060409625982cd05.tar.xz
penes-snac2-f8055ccfb52c5fdf9c08b608060409625982cd05.zip
mastoapi: added entrypoint /v1/followed_tags.
-rw-r--r--mastoapi.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/mastoapi.c b/mastoapi.c
index ca44751..9437f27 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -2483,6 +2483,40 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2483 } 2483 }
2484 else 2484 else
2485 if (strcmp(cmd, "/v1/followed_tags") == 0) { /** **/ 2485 if (strcmp(cmd, "/v1/followed_tags") == 0) { /** **/
2486 if (logged_in) {
2487 xs *r = xs_list_new();
2488 const xs_list *followed_hashtags = xs_dict_get_def(snac1.config,
2489 "followed_hashtags", xs_stock(XSTYPE_LIST));
2490 const char *hashtag;
2491
2492 xs_list_foreach(followed_hashtags, hashtag) {
2493 if (*hashtag == '#') {
2494 xs *d = xs_dict_new();
2495 xs *s = xs_fmt("%s?t=%s", srv_baseurl, hashtag + 1);
2496
2497 d = xs_dict_set(d, "name", hashtag + 1);
2498 d = xs_dict_set(d, "url", s);
2499 d = xs_dict_set(d, "history", xs_stock(XSTYPE_LIST));
2500
2501 r = xs_list_append(r, d);
2502 }
2503 }
2504
2505 *body = xs_json_dumps(r, 4);
2506 *ctype = "application/json";
2507 status = HTTP_STATUS_OK;
2508 }
2509 else
2510 status = HTTP_STATUS_UNAUTHORIZED;
2511 }
2512 else
2513 if (strcmp(cmd, "/v1/blocks") == 0) { /** **/
2514 *body = xs_dup("[]");
2515 *ctype = "application/json";
2516 status = HTTP_STATUS_OK;
2517 }
2518 else
2519 if (strcmp(cmd, "/v1/mutes") == 0) { /** **/
2486 *body = xs_dup("[]"); 2520 *body = xs_dup("[]");
2487 *ctype = "application/json"; 2521 *ctype = "application/json";
2488 status = HTTP_STATUS_OK; 2522 status = HTTP_STATUS_OK;