commit f8055cc

grunfink  ·  2025-06-16 03:11:33 +0000 UTC
parent d741647
mastoapi: added entrypoint /v1/followed_tags.
1 files changed,  +34, -0
+34, -0
 1@@ -2483,6 +2483,40 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 2     }
 3     else
 4     if (strcmp(cmd, "/v1/followed_tags") == 0) { /** **/
 5+        if (logged_in) {
 6+            xs *r = xs_list_new();
 7+            const xs_list *followed_hashtags = xs_dict_get_def(snac1.config,
 8+                        "followed_hashtags", xs_stock(XSTYPE_LIST));
 9+            const char *hashtag;
10+
11+            xs_list_foreach(followed_hashtags, hashtag) {
12+                if (*hashtag == '#') {
13+                    xs *d = xs_dict_new();
14+                    xs *s = xs_fmt("%s?t=%s", srv_baseurl, hashtag + 1);
15+
16+                    d = xs_dict_set(d, "name", hashtag + 1);
17+                    d = xs_dict_set(d, "url", s);
18+                    d = xs_dict_set(d, "history", xs_stock(XSTYPE_LIST));
19+
20+                    r = xs_list_append(r, d);
21+                }
22+            }
23+
24+            *body  = xs_json_dumps(r, 4);
25+            *ctype = "application/json";
26+            status = HTTP_STATUS_OK;
27+        }
28+        else
29+            status = HTTP_STATUS_UNAUTHORIZED;
30+    }
31+    else
32+    if (strcmp(cmd, "/v1/blocks") == 0) { /** **/
33+        *body  = xs_dup("[]");
34+        *ctype = "application/json";
35+        status = HTTP_STATUS_OK;
36+    }
37+    else
38+    if (strcmp(cmd, "/v1/mutes") == 0) { /** **/
39         *body  = xs_dup("[]");
40         *ctype = "application/json";
41         status = HTTP_STATUS_OK;