diff options
author | default <nobody@localhost> | 2023-04-11 11:00:06 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-04-11 11:00:06 +0200 |
commit | a4051f7f3774ac6a1e25ebb81a13c455e735b862 (patch) | |
tree | 1c9da223fb1ce9aff9b61c29381fc34d741381ed /mastoapi.c | |
parent | 79224ca2b53c61c1a13de25c7957ec98c85db61c (diff) |
Started work in /api/v1/statuses.
Diffstat (limited to 'mastoapi.c')
-rw-r--r-- | mastoapi.c | 46 |
1 files changed, 44 insertions, 2 deletions
@@ -603,10 +603,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, return 0; srv_debug(0, xs_fmt("mastoapi_get_handler %s", q_path)); - { +/* { xs *j = xs_json_dumps_pp(req, 4); printf("mastoapi get:\n%s\n", j); - } + }*/ int status = 404; xs_dict *args = xs_dict_get(req, "q_vars"); @@ -772,6 +772,48 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, *ctype = "application/json"; status = 200; } + else + if (xs_startswith(cmd, "/statuses/")) { + /* operations on a status */ + xs *l = xs_split(cmd, "/"); + const char *id = xs_list_get(l, 2); + const char *op = xs_list_get(l, 3); + + if (!xs_is_null(id)) { + xs *msg = NULL; + xs *out = NULL; + + /* skip the fake part of the id (the date) */ + id += 14; + + if (valid_status(timeline_get_by_md5(&snac, id, &msg))) { + if (op == NULL) { + /* return the status itself */ + } + else + if (strcmp(op, "context") == 0) { + /* return ancestors and children */ + srv_debug(0, xs_fmt("mastoapi status: context requested for %s", id)); + } + else + if (strcmp(op, "reblogged_by") == 0) { + /* return the list of boosts */ + } + else + if (strcmp(op, "favourited_by") == 0) { + /* return the list of likes */ + } + } + else + srv_debug(0, xs_fmt("mastoapi status: bad id %s", id)); + + if (out != NULL) { + *body = xs_json_dumps_pp(out, 4); + *ctype = "application/json"; + status = 200; + } + } + } /* user cleanup */ if (logged_in) |