aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrunfink <grunfink@comam.es>2025-05-18 08:43:31 +0200
committergrunfink <grunfink@comam.es>2025-05-18 08:43:31 +0200
commit0900f69f2a4d08086e60cd5d31beac73b65f25a7 (patch)
treec19505155c98d5baf8b9c8efd0f76d0091fd3178
parentee84140ecceb07dad8ea36cc5aa29b91bbb48a56 (diff)
mastoapi: added endpoint /v1/follow_requests.
-rw-r--r--mastoapi.c24
1 files changed, 20 insertions, 4 deletions
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) { /** **/