snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit 0900f69f2a4d08086e60cd5d31beac73b65f25a7
parent ee84140ecceb07dad8ea36cc5aa29b91bbb48a56
Author: grunfink <grunfink@comam.es>
Date:   Sun, 18 May 2025 08:43:31 +0200

mastoapi: added endpoint /v1/follow_requests.

Diffstat:
Mmastoapi.c | 24++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

diff --git 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) { /** **/