mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Added the mastodon account data.
This commit is contained in:
parent
668f69dca9
commit
0d4406e16c
1 changed files with 21 additions and 11 deletions
32
mastoapi.c
32
mastoapi.c
|
@ -677,20 +677,30 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (xs_startswith(cmd, "/accounts/") && xs_endswith(cmd, "/statuses")) {
|
if (xs_startswith(cmd, "/accounts/")) {
|
||||||
/* the public list of posts of a user */
|
/* account-related information */
|
||||||
xs *l = xs_split(cmd, "/");
|
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) {
|
if (uid != NULL && user_open(&snac2, uid)) {
|
||||||
snac snac2;
|
xs *out = NULL;
|
||||||
const char *uid = xs_list_get(l, 2);
|
|
||||||
|
|
||||||
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 *timeline = timeline_simple_list(&snac2, "public", 0, 256);
|
||||||
xs *out = xs_list_new();
|
|
||||||
xs_list *p = timeline;
|
xs_list *p = timeline;
|
||||||
xs_str *v;
|
xs_str *v;
|
||||||
|
|
||||||
|
out = xs_list_new();
|
||||||
|
|
||||||
while (xs_list_iter(&p, &v)) {
|
while (xs_list_iter(&p, &v)) {
|
||||||
xs *msg = NULL;
|
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);
|
*body = xs_json_dumps_pp(out, 4);
|
||||||
*ctype = "application/json";
|
*ctype = "application/json";
|
||||||
status = 200;
|
status = 200;
|
||||||
|
|
||||||
user_free(&snac2);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
srv_debug(0, xs_fmt("mastoapi account statuses: bad user '%s'", uid));
|
user_free(&snac2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue