diff options
| author | 2025-03-22 08:39:04 +0100 | |
|---|---|---|
| committer | 2025-03-22 08:39:04 +0100 | |
| commit | 0b4e8cac069d31de736137de08543ace912b728a (patch) | |
| tree | 8ae5c4de88b23e53b257412b550719a5c483c06f | |
| parent | mastoapi: Added support for /api/v1/instance/peers. (diff) | |
| download | penes-snac2-0b4e8cac069d31de736137de08543ace912b728a.tar.gz penes-snac2-0b4e8cac069d31de736137de08543ace912b728a.tar.xz penes-snac2-0b4e8cac069d31de736137de08543ace912b728a.zip | |
mastoapi: fixed instance peers to return only the domains.
| -rw-r--r-- | mastoapi.c | 12 |
1 files changed, 11 insertions, 1 deletions
| @@ -2259,8 +2259,18 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2259 | if (strcmp(cmd, "/v1/instance/peers") == 0) { /** **/ | 2259 | if (strcmp(cmd, "/v1/instance/peers") == 0) { /** **/ |
| 2260 | /* get the collected inbox list as the instances "this domain is aware of" */ | 2260 | /* get the collected inbox list as the instances "this domain is aware of" */ |
| 2261 | xs *list = inbox_list(); | 2261 | xs *list = inbox_list(); |
| 2262 | xs *peers = xs_list_new(); | ||
| 2263 | const char *inbox; | ||
| 2262 | 2264 | ||
| 2263 | *body = xs_json_dumps(list, 4); | 2265 | xs_list_foreach(list, inbox) { |
| 2266 | xs *l = xs_split(inbox, "/"); | ||
| 2267 | const char *domain = xs_list_get(l, 2); | ||
| 2268 | |||
| 2269 | if (xs_is_string(domain)) | ||
| 2270 | peers = xs_list_append(peers, domain); | ||
| 2271 | } | ||
| 2272 | |||
| 2273 | *body = xs_json_dumps(peers, 4); | ||
| 2264 | *ctype = "application/json"; | 2274 | *ctype = "application/json"; |
| 2265 | status = HTTP_STATUS_OK; | 2275 | status = HTTP_STATUS_OK; |
| 2266 | } | 2276 | } |