mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-26 06:53:37 +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
30
mastoapi.c
30
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, "/");
|
||||||
|
|
||||||
if (xs_list_len(l) == 4) {
|
|
||||||
snac snac2;
|
|
||||||
const char *uid = xs_list_get(l, 2);
|
const char *uid = xs_list_get(l, 2);
|
||||||
|
const char *opt = xs_list_get(l, 3);
|
||||||
|
snac snac2;
|
||||||
|
|
||||||
if (user_open(&snac2, uid)) {
|
if (uid != NULL && user_open(&snac2, uid)) {
|
||||||
|
xs *out = NULL;
|
||||||
|
|
||||||
|
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,16 +714,16 @@ 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);
|
user_free(&snac2);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
srv_debug(0, xs_fmt("mastoapi account statuses: bad user '%s'", uid));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcmp(cmd, "/timelines/home") == 0) {
|
if (strcmp(cmd, "/timelines/home") == 0) {
|
||||||
|
|
Loading…
Reference in a new issue