diff options
| author | 2025-05-18 08:43:31 +0200 | |
|---|---|---|
| committer | 2025-05-18 08:43:31 +0200 | |
| commit | 0900f69f2a4d08086e60cd5d31beac73b65f25a7 (patch) | |
| tree | c19505155c98d5baf8b9c8efd0f76d0091fd3178 | |
| parent | Added a pending follow request count next to the "people" link. (diff) | |
| download | snac2-0900f69f2a4d08086e60cd5d31beac73b65f25a7.tar.gz snac2-0900f69f2a4d08086e60cd5d31beac73b65f25a7.tar.xz snac2-0900f69f2a4d08086e60cd5d31beac73b65f25a7.zip | |
mastoapi: added endpoint /v1/follow_requests.
| -rw-r--r-- | mastoapi.c | 24 |
1 files changed, 20 insertions, 4 deletions
| @@ -2109,10 +2109,26 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2109 | } | 2109 | } |
| 2110 | else | 2110 | else |
| 2111 | if (strcmp(cmd, "/v1/follow_requests") == 0) { /** **/ | 2111 | if (strcmp(cmd, "/v1/follow_requests") == 0) { /** **/ |
| 2112 | /* snac does not support optional follow confirmations */ | 2112 | if (logged_in) { |
| 2113 | *body = xs_dup("[]"); | 2113 | xs *pend = pending_list(&snac1); |
| 2114 | *ctype = "application/json"; | 2114 | xs *resp = xs_list_new(); |
| 2115 | status = HTTP_STATUS_OK; | 2115 | const char *id; |
| 2116 | |||
| 2117 | xs_list_foreach(pend, id) { | ||
| 2118 | xs *actor = NULL; | ||
| 2119 | |||
| 2120 | if (valid_status(object_get(id, &actor))) { | ||
| 2121 | xs *acct = mastoapi_account(&snac1, actor); | ||
| 2122 | |||
| 2123 | if (acct) | ||
| 2124 | resp = xs_list_append(resp, acct); | ||
| 2125 | } | ||
| 2126 | } | ||
| 2127 | |||
| 2128 | *body = xs_json_dumps(resp, 4); | ||
| 2129 | *ctype = "application/json"; | ||
| 2130 | status = HTTP_STATUS_OK; | ||
| 2131 | } | ||
| 2116 | } | 2132 | } |
| 2117 | else | 2133 | else |
| 2118 | if (strcmp(cmd, "/v1/announcements") == 0) { /** **/ | 2134 | if (strcmp(cmd, "/v1/announcements") == 0) { /** **/ |