summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-04-29 10:48:48 +0200
committerGravatar default2024-04-29 10:48:48 +0200
commitda18efd288bc8e69a0f755e576e3ba14dfedbcb3 (patch)
tree0b7eb71ae153dc5f806b5e7ecf7421611c8def13
parentMore work in lists. (diff)
downloadpenes-snac2-da18efd288bc8e69a0f755e576e3ba14dfedbcb3.tar.gz
penes-snac2-da18efd288bc8e69a0f755e576e3ba14dfedbcb3.tar.xz
penes-snac2-da18efd288bc8e69a0f755e576e3ba14dfedbcb3.zip
More tweaks to mastoapi lists.
-rw-r--r--mastoapi.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 6316951..0cdb4bf 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1863,22 +1863,52 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1863 if (xs_startswith(cmd, "/v1/lists/")) { /** list information **/ 1863 if (xs_startswith(cmd, "/v1/lists/")) { /** list information **/
1864 if (logged_in) { 1864 if (logged_in) {
1865 xs *l = xs_split(cmd, "/"); 1865 xs *l = xs_split(cmd, "/");
1866 char *op = xs_list_get(l, -1); 1866 char *p = xs_list_get(l, -1);
1867 char *id = xs_list_get(l, -2);
1868 1867
1869 if (op && id && xs_is_hex(id)) { 1868 if (p) {
1870 if (strcmp(op, "accounts") == 0) { 1869 if (strcmp(p, "accounts") == 0) {
1871 xs *actors = list_content(&snac1, id, NULL, 0); 1870 p = xs_list_get(l, -2);
1871
1872 if (p && xs_is_hex(p)) {
1873 xs *actors = list_content(&snac1, p, NULL, 0);
1874 xs *out = xs_list_new();
1875 int c = 0;
1876 char *v;
1877
1878 while (xs_list_next(actors, &v, &c)) {
1879 xs *actor = NULL;
1880
1881 if (valid_status(object_get_by_md5(v, &actor))) {
1882 xs *acct = mastoapi_account(actor);
1883 out = xs_list_append(out, acct);
1884 }
1885 }
1886
1887 *body = xs_json_dumps(out, 4);
1888 *ctype = "application/json";
1889 status = 200;
1890 }
1891 }
1892 else
1893 if (xs_is_hex(p)) {
1872 xs *out = xs_list_new(); 1894 xs *out = xs_list_new();
1895 xs *lol = list_maint(&snac1, NULL, 0);
1873 int c = 0; 1896 int c = 0;
1874 char *v; 1897 xs_list *v;
1898
1899 while (xs_list_next(lol, &v, &c)) {
1900 char *id = xs_list_get(v, 0);
1901
1902 if (id && strcmp(id, p) == 0) {
1903 xs *d = xs_dict_new();
1875 1904
1876 while (xs_list_next(actors, &v, &c)) { 1905 d = xs_dict_append(d, "id", p);
1877 xs *actor = NULL; 1906 d = xs_dict_append(d, "title", xs_list_get(v, 1));
1907 d = xs_dict_append(d, "replies_policy", "list");
1908 d = xs_dict_append(d, "exclusive", xs_stock(XSTYPE_FALSE));
1878 1909
1879 if (valid_status(object_get_by_md5(v, &actor))) { 1910 out = xs_list_append(out, d);
1880 xs *acct = mastoapi_account(actor); 1911 break;
1881 out = xs_list_append(out, acct);
1882 } 1912 }
1883 } 1913 }
1884 1914