diff options
author | default <nobody@localhost> | 2023-04-12 18:54:20 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-04-12 18:54:20 +0200 |
commit | 0d4406e16c871c73f708a06452f2950f8b27f748 (patch) | |
tree | ee13db0b3998584a0ea6a363cd108807c2a40e41 /mastoapi.c | |
parent | 668f69dca90c3449a19ab21482a8b198ea11adae (diff) |
Added the mastodon account data.
Diffstat (limited to 'mastoapi.c')
-rw-r--r-- | mastoapi.c | 32 |
1 files changed, 21 insertions, 11 deletions
@@ -677,20 +677,30 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, } } else - if (xs_startswith(cmd, "/accounts/") && xs_endswith(cmd, "/statuses")) { - /* the public list of posts of a user */ + if (xs_startswith(cmd, "/accounts/")) { + /* account-related information */ xs *l = xs_split(cmd, "/"); + const char *uid = xs_list_get(l, 2); + const char *opt = xs_list_get(l, 3); + snac snac2; - if (xs_list_len(l) == 4) { - snac snac2; - const char *uid = xs_list_get(l, 2); + if (uid != NULL && user_open(&snac2, uid)) { + xs *out = NULL; - if (user_open(&snac2, uid)) { + if (opt == NULL) { + /* account information */ + xs *actor = msg_actor(&snac2); + out = mastoapi_account(&snac2, actor); + } + else + if (strcmp(opt, "statuses") == 0) { + /* the public list of posts of a user */ xs *timeline = timeline_simple_list(&snac2, "public", 0, 256); - xs *out = xs_list_new(); xs_list *p = timeline; xs_str *v; + out = xs_list_new(); + while (xs_list_iter(&p, &v)) { xs *msg = NULL; @@ -704,15 +714,15 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, } } } + } + if (out != NULL) { *body = xs_json_dumps_pp(out, 4); *ctype = "application/json"; status = 200; - - user_free(&snac2); } - else - srv_debug(0, xs_fmt("mastoapi account statuses: bad user '%s'", uid)); + + user_free(&snac2); } } else |