commit 61ef7a8

grunfink  ·  2026-08-30 14:38:58 +0000 UTC
parent 62166d3
Fixed error in notification filtering.
3 files changed,  +17, -6
M data.c
M html.c
M snac.h
M data.c
+12, -2
 1@@ -3576,7 +3576,7 @@ xs_list *notify_list(snac *snac, int skip, int show)
 2 }
 3 
 4 
 5-xs_list *notify_filter_list(snac *snac, xs_list *notifs)
 6+xs_list *notify_filter_list(snac *snac, xs_list *notifs, int skip, int show)
 7 /* apply user-defined notification filter to IDs */
 8 {
 9     const xs_dict *n_filter = xs_dict_get(snac->config, "notify_filter");
10@@ -3633,7 +3633,17 @@ xs_list *notify_filter_list(snac *snac, xs_list *notifs)
11             continue;
12         if (strcmp(type, "Announce") == 0 && !n_ann_on)
13             continue;
14+
15+        if (skip) {
16+            skip--;
17+            continue;
18+        }
19+
20         flt = xs_list_append(flt, v);
21+        show--;
22+
23+        if (show == 0)
24+            break;
25     }
26     return flt;
27 }
28@@ -3644,7 +3654,7 @@ int notify_new_num(snac *snac)
29 {
30     xs *t = notify_check_time(snac, 0);
31     xs *lst_unfilt = notify_list(snac, 0, XS_ALL);
32-    xs *lst = notify_filter_list(snac, lst_unfilt);
33+    xs *lst = notify_filter_list(snac, lst_unfilt, 0, XS_ALL);
34     int cnt = 0;
35 
36     xs_list *p = lst;
M html.c
+4, -3
 1@@ -4267,7 +4267,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
 2     if (xs_is_true(xs_dict_get(srv_config, "proxy_media")))
 3         proxy = user->actor;
 4 
 5-    xs *n_list_unfilt = notify_list(user, skip, show);
 6+    xs *n_list_unfilt = notify_list(user, 0, XS_ALL);
 7     xs *n_time = notify_check_time(user, 0);
 8 
 9     xs_html *body = html_user_body(user, 0);
10@@ -4278,7 +4278,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
11         user->tz = xs_dict_get_def(user->config, "tz", "UTC"); // previous line invalidates user->tz
12         n_filter = xs_dict_get(user->config, "notify_filter");
13     }
14-    xs *n_list = notify_filter_list(user, n_list_unfilt);
15+    xs *n_list = notify_filter_list(user, n_list_unfilt, skip, show);
16     /* all filters are true by default */
17     const xs_val *n_def = xs_stock( XSTYPE_TRUE );
18     int n_likes_on  = xs_is_true(xs_dict_get_def(n_filter, "likes", n_def));
19@@ -4607,7 +4607,8 @@ xs_str *html_notifications(snac *user, int skip, int show)
20                 xs_html_text(L("None"))));
21 
22     /* add the navigation footer */
23-    xs *next_p = notify_list(user, skip + show, 1);
24+    xs *next_p = notify_filter_list(user, n_list_unfilt, skip + show, 1);
25+
26     if (xs_list_len(next_p)) {
27         xs *url = xs_fmt("%s/notifications?skip=%d&show=%d",
28             user->actor, skip + show, show);
M snac.h
+1, -1
1@@ -291,7 +291,7 @@ void notify_add(snac *snac, const char *type, const char *utype,
2 xs_dict *notify_get(snac *snac, const char *id);
3 int notify_new_num(snac *snac);
4 xs_list *notify_list(snac *snac, int skip, int show);
5-xs_list *notify_filter_list(snac *snac, xs_list *ids);
6+xs_list *notify_filter_list(snac *snac, xs_list *ids, int skip, int show);
7 void notify_clear(snac *snac);
8 
9 xs_dict *markers_get(snac *snac, const xs_list *markers);