commit 7c9846ef3ebc7fd458ce23aab243efa0089f9901
parent d4711bbfba90fae8ff42202b93eb2e1b6955f50b
Author: default <nobody@localhost>
Date: Mon, 10 Apr 2023 16:08:26 +0200
Added /api/v1/instance.
Diffstat:
1 file changed, 29 insertions(+), 0 deletions(-)
diff --git a/mastoapi.c b/mastoapi.c
@@ -732,6 +732,35 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
if (strcmp(cmd, "/timelines/public") == 0) {
/* the public timeline */
}
+ else
+ if (strcmp(cmd, "/instance") == 0) {
+ /* returns an instance object */
+ xs *ins = xs_dict_new();
+ const char *host = xs_dict_get(srv_config, "host");
+
+ ins = xs_dict_append(ins, "domain", host);
+ ins = xs_dict_append(ins, "title", host);
+ ins = xs_dict_append(ins, "version", "4.0.0 (not true; really " USER_AGENT ")");
+ ins = xs_dict_append(ins, "source_url", "https:/" "/comam.es/snac-source");
+ ins = xs_dict_append(ins, "description", host);
+
+ xs *susie = xs_fmt("%s/susie.png", srv_baseurl);
+ xs *d1 = xs_dict_new();
+ d1 = xs_dict_append(d1, "url", susie);
+ ins = xs_dict_append(ins, "thumbnail", d1);
+
+ xs *d2 = xs_dict_new();
+ d2 = xs_dict_append(d2, "email", "admin@localhost");
+ ins = xs_dict_append(ins, "contact", d2);
+
+ xs *l1 = xs_list_new();
+ ins = xs_dict_append(ins, "rules", l1);
+ ins = xs_dict_append(ins, "languages", l1);
+
+ *body = xs_json_dumps_pp(ins, 4);
+ *ctype = "application/json";
+ status = 200;
+ }
/* user cleanup */
if (logged_in)