diff options
author | default <nobody@localhost> | 2023-04-10 16:08:26 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-04-10 16:08:26 +0200 |
commit | 7c9846ef3ebc7fd458ce23aab243efa0089f9901 (patch) | |
tree | 6464dc83cc4d970f56dbea776c71f6b3b3c14dfc /mastoapi.c | |
parent | d4711bbfba90fae8ff42202b93eb2e1b6955f50b (diff) |
Added /api/v1/instance.
Diffstat (limited to 'mastoapi.c')
-rw-r--r-- | mastoapi.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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) |