mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
More tweaks to mastoapi lists.
This commit is contained in:
parent
f1221808a8
commit
da18efd288
1 changed files with 41 additions and 11 deletions
40
mastoapi.c
40
mastoapi.c
|
@ -1863,12 +1863,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
if (xs_startswith(cmd, "/v1/lists/")) { /** list information **/
|
if (xs_startswith(cmd, "/v1/lists/")) { /** list information **/
|
||||||
if (logged_in) {
|
if (logged_in) {
|
||||||
xs *l = xs_split(cmd, "/");
|
xs *l = xs_split(cmd, "/");
|
||||||
char *op = xs_list_get(l, -1);
|
char *p = xs_list_get(l, -1);
|
||||||
char *id = xs_list_get(l, -2);
|
|
||||||
|
|
||||||
if (op && id && xs_is_hex(id)) {
|
if (p) {
|
||||||
if (strcmp(op, "accounts") == 0) {
|
if (strcmp(p, "accounts") == 0) {
|
||||||
xs *actors = list_content(&snac1, id, NULL, 0);
|
p = xs_list_get(l, -2);
|
||||||
|
|
||||||
|
if (p && xs_is_hex(p)) {
|
||||||
|
xs *actors = list_content(&snac1, p, NULL, 0);
|
||||||
xs *out = xs_list_new();
|
xs *out = xs_list_new();
|
||||||
int c = 0;
|
int c = 0;
|
||||||
char *v;
|
char *v;
|
||||||
|
@ -1882,6 +1884,34 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*body = xs_json_dumps(out, 4);
|
||||||
|
*ctype = "application/json";
|
||||||
|
status = 200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (xs_is_hex(p)) {
|
||||||
|
xs *out = xs_list_new();
|
||||||
|
xs *lol = list_maint(&snac1, NULL, 0);
|
||||||
|
int c = 0;
|
||||||
|
xs_list *v;
|
||||||
|
|
||||||
|
while (xs_list_next(lol, &v, &c)) {
|
||||||
|
char *id = xs_list_get(v, 0);
|
||||||
|
|
||||||
|
if (id && strcmp(id, p) == 0) {
|
||||||
|
xs *d = xs_dict_new();
|
||||||
|
|
||||||
|
d = xs_dict_append(d, "id", p);
|
||||||
|
d = xs_dict_append(d, "title", xs_list_get(v, 1));
|
||||||
|
d = xs_dict_append(d, "replies_policy", "list");
|
||||||
|
d = xs_dict_append(d, "exclusive", xs_stock(XSTYPE_FALSE));
|
||||||
|
|
||||||
|
out = xs_list_append(out, d);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*body = xs_json_dumps(out, 4);
|
*body = xs_json_dumps(out, 4);
|
||||||
*ctype = "application/json";
|
*ctype = "application/json";
|
||||||
status = 200;
|
status = 200;
|
||||||
|
|
Loading…
Reference in a new issue