summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorGravatar grunfink2025-05-14 08:48:15 +0200
committerGravatar grunfink2025-05-14 08:48:15 +0200
commit8ae0089bdb3c246810013de5c9541072b2593f00 (patch)
treefb626e925bc8c236ceeba3e0f19811efaeea9229 /mastoapi.c
parentVersion 2.77 RELEASED. (diff)
downloadsnac2-8ae0089bdb3c246810013de5c9541072b2593f00.tar.gz
snac2-8ae0089bdb3c246810013de5c9541072b2593f00.tar.xz
snac2-8ae0089bdb3c246810013de5c9541072b2593f00.zip
mastoapi: Also process the types[] argument in notifications.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/mastoapi.c b/mastoapi.c
index e6acb11..6a22189 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1874,13 +1874,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1874 if (logged_in) { 1874 if (logged_in) {
1875 xs *l = notify_list(&snac1, 0, 64); 1875 xs *l = notify_list(&snac1, 0, 64);
1876 xs *out = xs_list_new(); 1876 xs *out = xs_list_new();
1877 const xs_dict *v; 1877 const char *v;
1878 const xs_list *excl = xs_dict_get(args, "exclude_types[]"); 1878 const xs_list *excl = xs_dict_get(args, "exclude_types[]");
1879 const xs_list *incl = xs_dict_get(args, "types[]");
1879 const char *min_id = xs_dict_get(args, "min_id"); 1880 const char *min_id = xs_dict_get(args, "min_id");
1880 const char *max_id = xs_dict_get(args, "max_id"); 1881 const char *max_id = xs_dict_get(args, "max_id");
1881 const char *limit = xs_dict_get(args, "limit"); 1882 const char *limit = xs_dict_get(args, "limit");
1882 int limit_count = 0; 1883 int limit_count = 0;
1883 if (!xs_is_null(limit)) { 1884 if (xs_is_string(limit)) {
1884 limit_count = atoi(limit); 1885 limit_count = atoi(limit);
1885 } 1886 }
1886 1887
@@ -1899,11 +1900,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1899 const char *utype = xs_dict_get(noti, "utype"); 1900 const char *utype = xs_dict_get(noti, "utype");
1900 const char *objid = xs_dict_get(noti, "objid"); 1901 const char *objid = xs_dict_get(noti, "objid");
1901 const char *id = xs_dict_get(noti, "id"); 1902 const char *id = xs_dict_get(noti, "id");
1903 const char *actid = xs_dict_get(noti, "actor");
1902 xs *fid = xs_replace(id, ".", ""); 1904 xs *fid = xs_replace(id, ".", "");
1903 xs *actor = NULL; 1905 xs *actor = NULL;
1904 xs *entry = NULL; 1906 xs *entry = NULL;
1905 1907
1906 if (!valid_status(actor_get(xs_dict_get(noti, "actor"), &actor))) 1908 if (!valid_status(actor_get(actid, &actor)))
1907 continue; 1909 continue;
1908 1910
1909 if (objid != NULL && !valid_status(object_get(objid, &entry))) 1911 if (objid != NULL && !valid_status(object_get(objid, &entry)))
@@ -1944,7 +1946,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1944 continue; 1946 continue;
1945 1947
1946 /* excluded type? */ 1948 /* excluded type? */
1947 if (!xs_is_null(excl) && xs_list_in(excl, type) != -1) 1949 if (xs_is_list(excl) && xs_list_in(excl, type) != -1)
1950 continue;
1951
1952 /* included type? */
1953 if (xs_is_list(incl) && xs_list_in(incl, type) == -1)
1948 continue; 1954 continue;
1949 1955
1950 xs *mn = xs_dict_new(); 1956 xs *mn = xs_dict_new();
@@ -1970,10 +1976,9 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1970 } 1976 }
1971 1977
1972 out = xs_list_append(out, mn); 1978 out = xs_list_append(out, mn);
1973 if (!xs_is_null(limit)) { 1979
1974 if (--limit_count <= 0) 1980 if (--limit_count <= 0)
1975 break; 1981 break;
1976 }
1977 } 1982 }
1978 1983
1979 srv_debug(1, xs_fmt("mastoapi_notifications count %d", xs_list_len(out))); 1984 srv_debug(1, xs_fmt("mastoapi_notifications count %d", xs_list_len(out)));