commit 0900f69
grunfink
·
2025-05-18 06:43:31 +0000 UTC
parent ee84140
mastoapi: added endpoint /v1/follow_requests.
1 files changed,
+20,
-4
+20,
-4
1@@ -2109,10 +2109,26 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 }
3 else
4 if (strcmp(cmd, "/v1/follow_requests") == 0) { /** **/
5- /* snac does not support optional follow confirmations */
6- *body = xs_dup("[]");
7- *ctype = "application/json";
8- status = HTTP_STATUS_OK;
9+ if (logged_in) {
10+ xs *pend = pending_list(&snac1);
11+ xs *resp = xs_list_new();
12+ const char *id;
13+
14+ xs_list_foreach(pend, id) {
15+ xs *actor = NULL;
16+
17+ if (valid_status(object_get(id, &actor))) {
18+ xs *acct = mastoapi_account(&snac1, actor);
19+
20+ if (acct)
21+ resp = xs_list_append(resp, acct);
22+ }
23+ }
24+
25+ *body = xs_json_dumps(resp, 4);
26+ *ctype = "application/json";
27+ status = HTTP_STATUS_OK;
28+ }
29 }
30 else
31 if (strcmp(cmd, "/v1/announcements") == 0) { /** **/