commit 8ae0089
grunfink
·
2025-05-14 06:48:15 +0000 UTC
parent f321905
mastoapi: Also process the types[] argument in notifications.
1 files changed,
+13,
-8
+13,
-8
1@@ -1874,13 +1874,14 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 if (logged_in) {
3 xs *l = notify_list(&snac1, 0, 64);
4 xs *out = xs_list_new();
5- const xs_dict *v;
6+ const char *v;
7 const xs_list *excl = xs_dict_get(args, "exclude_types[]");
8+ const xs_list *incl = xs_dict_get(args, "types[]");
9 const char *min_id = xs_dict_get(args, "min_id");
10 const char *max_id = xs_dict_get(args, "max_id");
11 const char *limit = xs_dict_get(args, "limit");
12 int limit_count = 0;
13- if (!xs_is_null(limit)) {
14+ if (xs_is_string(limit)) {
15 limit_count = atoi(limit);
16 }
17
18@@ -1899,11 +1900,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
19 const char *utype = xs_dict_get(noti, "utype");
20 const char *objid = xs_dict_get(noti, "objid");
21 const char *id = xs_dict_get(noti, "id");
22+ const char *actid = xs_dict_get(noti, "actor");
23 xs *fid = xs_replace(id, ".", "");
24 xs *actor = NULL;
25 xs *entry = NULL;
26
27- if (!valid_status(actor_get(xs_dict_get(noti, "actor"), &actor)))
28+ if (!valid_status(actor_get(actid, &actor)))
29 continue;
30
31 if (objid != NULL && !valid_status(object_get(objid, &entry)))
32@@ -1944,7 +1946,11 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
33 continue;
34
35 /* excluded type? */
36- if (!xs_is_null(excl) && xs_list_in(excl, type) != -1)
37+ if (xs_is_list(excl) && xs_list_in(excl, type) != -1)
38+ continue;
39+
40+ /* included type? */
41+ if (xs_is_list(incl) && xs_list_in(incl, type) == -1)
42 continue;
43
44 xs *mn = xs_dict_new();
45@@ -1970,10 +1976,9 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
46 }
47
48 out = xs_list_append(out, mn);
49- if (!xs_is_null(limit)) {
50- if (--limit_count <= 0)
51- break;
52- }
53+
54+ if (--limit_count <= 0)
55+ break;
56 }
57
58 srv_debug(1, xs_fmt("mastoapi_notifications count %d", xs_list_len(out)));