commit 7c9846e
default
·
2023-04-10 14:08:26 +0000 UTC
parent d4711bb
Added /api/v1/instance.
1 files changed,
+29,
-0
+29,
-0
1@@ -732,6 +732,35 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 if (strcmp(cmd, "/timelines/public") == 0) {
3 /* the public timeline */
4 }
5+ else
6+ if (strcmp(cmd, "/instance") == 0) {
7+ /* returns an instance object */
8+ xs *ins = xs_dict_new();
9+ const char *host = xs_dict_get(srv_config, "host");
10+
11+ ins = xs_dict_append(ins, "domain", host);
12+ ins = xs_dict_append(ins, "title", host);
13+ ins = xs_dict_append(ins, "version", "4.0.0 (not true; really " USER_AGENT ")");
14+ ins = xs_dict_append(ins, "source_url", "https:/" "/comam.es/snac-source");
15+ ins = xs_dict_append(ins, "description", host);
16+
17+ xs *susie = xs_fmt("%s/susie.png", srv_baseurl);
18+ xs *d1 = xs_dict_new();
19+ d1 = xs_dict_append(d1, "url", susie);
20+ ins = xs_dict_append(ins, "thumbnail", d1);
21+
22+ xs *d2 = xs_dict_new();
23+ d2 = xs_dict_append(d2, "email", "admin@localhost");
24+ ins = xs_dict_append(ins, "contact", d2);
25+
26+ xs *l1 = xs_list_new();
27+ ins = xs_dict_append(ins, "rules", l1);
28+ ins = xs_dict_append(ins, "languages", l1);
29+
30+ *body = xs_json_dumps_pp(ins, 4);
31+ *ctype = "application/json";
32+ status = 200;
33+ }
34
35 /* user cleanup */
36 if (logged_in)