commit 0b4e8ca

default  ·  2025-03-22 07:39:04 +0000 UTC
parent 2057327
mastoapi: fixed instance peers to return only the domains.
1 files changed,  +11, -1
+11, -1
 1@@ -2259,8 +2259,18 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 2     if (strcmp(cmd, "/v1/instance/peers") == 0) { /** **/
 3         /* get the collected inbox list as the instances "this domain is aware of" */
 4         xs *list = inbox_list();
 5+        xs *peers = xs_list_new();
 6+        const char *inbox;
 7 
 8-        *body  = xs_json_dumps(list, 4);
 9+        xs_list_foreach(list, inbox) {
10+            xs *l = xs_split(inbox, "/");
11+            const char *domain = xs_list_get(l, 2);
12+
13+            if (xs_is_string(domain))
14+                peers = xs_list_append(peers, domain);
15+        }
16+
17+        *body  = xs_json_dumps(peers, 4);
18         *ctype = "application/json";
19         status = HTTP_STATUS_OK;
20     }