summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 791d3b8..3550264 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -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)