From 0900f69f2a4d08086e60cd5d31beac73b65f25a7 Mon Sep 17 00:00:00 2001 From: grunfink Date: Sun, 18 May 2025 08:43:31 +0200 Subject: mastoapi: added endpoint /v1/follow_requests. --- mastoapi.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'mastoapi.c') diff --git a/mastoapi.c b/mastoapi.c index 6a22189..c216a0b 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -2109,10 +2109,26 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, } else if (strcmp(cmd, "/v1/follow_requests") == 0) { /** **/ - /* snac does not support optional follow confirmations */ - *body = xs_dup("[]"); - *ctype = "application/json"; - status = HTTP_STATUS_OK; + if (logged_in) { + xs *pend = pending_list(&snac1); + xs *resp = xs_list_new(); + const char *id; + + xs_list_foreach(pend, id) { + xs *actor = NULL; + + if (valid_status(object_get(id, &actor))) { + xs *acct = mastoapi_account(&snac1, actor); + + if (acct) + resp = xs_list_append(resp, acct); + } + } + + *body = xs_json_dumps(resp, 4); + *ctype = "application/json"; + status = HTTP_STATUS_OK; + } } else if (strcmp(cmd, "/v1/announcements") == 0) { /** **/ -- cgit v1.2.3