commit cd05398

grunfink  ·  2025-08-14 09:17:49 +0000 UTC
parent 4fc7d18
Added nodeinfo 2.1 support.
2 files changed,  +18, -3
M snac.h
+17, -3
 1@@ -283,9 +283,10 @@ int server_get_handler(xs_dict *req, const char *q_path,
 2         status = HTTP_STATUS_OK;
 3         *ctype = "application/json; charset=utf-8";
 4         *body  = xs_fmt("{\"links\":["
 5-            "{\"rel\":\"http:/" "/nodeinfo.diaspora.software/ns/schema/2.0\","
 6-            "\"href\":\"%s/nodeinfo_2_0\"}]}",
 7-            srv_baseurl);
 8+            "{\"rel\":\"http:/" "/nodeinfo.diaspora.software/ns/schema/2.0\",\"href\":\"%s/nodeinfo_2_0\"},"
 9+            "{\"rel\":\"http:/" "/nodeinfo.diaspora.software/ns/schema/2.1\",\"href\":\"%s/nodeinfo_2_1\"}"
10+            "]}",
11+            srv_baseurl, srv_baseurl);
12     }
13     else
14     if (strcmp(q_path, "/.well-known/host-meta") == 0) {
15@@ -303,6 +304,19 @@ int server_get_handler(xs_dict *req, const char *q_path,
16         *body  = nodeinfo_2_0();
17     }
18     else
19+    if (strcmp(q_path, "/nodeinfo_2_1") == 0) {
20+        xs *s = nodeinfo_2_0();
21+        xs *j = xs_json_loads(s);
22+
23+        j = xs_dict_set(j, "version", "2.1");
24+        j = xs_dict_set_path(j, "software.repository", WHAT_IS_SNAC_URL);
25+        j = xs_dict_set_path(j, "software.homepage", SNAC_DOC_URL);
26+
27+        status = HTTP_STATUS_OK;
28+        *ctype = "application/json; charset=utf-8";
29+        *body  = xs_json_dumps(j, 4);
30+    }
31+    else
32     if (strcmp(q_path, "/robots.txt") == 0) {
33         status = HTTP_STATUS_OK;
34         *ctype = "text/plain";
M snac.h
+1, -0
1@@ -6,6 +6,7 @@
2 #define USER_AGENT "snac/" VERSION
3 
4 #define WHAT_IS_SNAC_URL "https:/" "/comam.es/what-is-snac"
5+#define SNAC_DOC_URL "https:/" "/comam.es/snac-doc"
6 
7 #define DIR_PERM 00770
8 #define DIR_PERM_ADD 02770