Bläddra i källkod

Fixed error in notification filtering.

grunfink 2 veckor sedan
förälder
incheckning
61ef7a8618
3 ändrade filer med 17 tillägg och 6 borttagningar
  1. 12 2
      data.c
  2. 4 3
      html.c
  3. 1 1
      snac.h

+ 12 - 2
data.c

@@ -3576,7 +3576,7 @@ xs_list *notify_list(snac *snac, int skip, int show)
 }
 }
 
 
 
 
-xs_list *notify_filter_list(snac *snac, xs_list *notifs)
+xs_list *notify_filter_list(snac *snac, xs_list *notifs, int skip, int show)
 /* apply user-defined notification filter to IDs */
 /* apply user-defined notification filter to IDs */
 {
 {
     const xs_dict *n_filter = xs_dict_get(snac->config, "notify_filter");
     const xs_dict *n_filter = xs_dict_get(snac->config, "notify_filter");
@@ -3633,7 +3633,17 @@ xs_list *notify_filter_list(snac *snac, xs_list *notifs)
             continue;
             continue;
         if (strcmp(type, "Announce") == 0 && !n_ann_on)
         if (strcmp(type, "Announce") == 0 && !n_ann_on)
             continue;
             continue;
+
+        if (skip) {
+            skip--;
+            continue;
+        }
+
         flt = xs_list_append(flt, v);
         flt = xs_list_append(flt, v);
+        show--;
+
+        if (show == 0)
+            break;
     }
     }
     return flt;
     return flt;
 }
 }
@@ -3644,7 +3654,7 @@ int notify_new_num(snac *snac)
 {
 {
     xs *t = notify_check_time(snac, 0);
     xs *t = notify_check_time(snac, 0);
     xs *lst_unfilt = notify_list(snac, 0, XS_ALL);
     xs *lst_unfilt = notify_list(snac, 0, XS_ALL);
-    xs *lst = notify_filter_list(snac, lst_unfilt);
+    xs *lst = notify_filter_list(snac, lst_unfilt, 0, XS_ALL);
     int cnt = 0;
     int cnt = 0;
 
 
     xs_list *p = lst;
     xs_list *p = lst;

+ 4 - 3
html.c

@@ -4267,7 +4267,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
     if (xs_is_true(xs_dict_get(srv_config, "proxy_media")))
     if (xs_is_true(xs_dict_get(srv_config, "proxy_media")))
         proxy = user->actor;
         proxy = user->actor;
 
 
-    xs *n_list_unfilt = notify_list(user, skip, show);
+    xs *n_list_unfilt = notify_list(user, 0, XS_ALL);
     xs *n_time = notify_check_time(user, 0);
     xs *n_time = notify_check_time(user, 0);
 
 
     xs_html *body = html_user_body(user, 0);
     xs_html *body = html_user_body(user, 0);
@@ -4278,7 +4278,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
         user->tz = xs_dict_get_def(user->config, "tz", "UTC"); // previous line invalidates user->tz
         user->tz = xs_dict_get_def(user->config, "tz", "UTC"); // previous line invalidates user->tz
         n_filter = xs_dict_get(user->config, "notify_filter");
         n_filter = xs_dict_get(user->config, "notify_filter");
     }
     }
-    xs *n_list = notify_filter_list(user, n_list_unfilt);
+    xs *n_list = notify_filter_list(user, n_list_unfilt, skip, show);
     /* all filters are true by default */
     /* all filters are true by default */
     const xs_val *n_def = xs_stock( XSTYPE_TRUE );
     const xs_val *n_def = xs_stock( XSTYPE_TRUE );
     int n_likes_on  = xs_is_true(xs_dict_get_def(n_filter, "likes", n_def));
     int n_likes_on  = xs_is_true(xs_dict_get_def(n_filter, "likes", n_def));
@@ -4607,7 +4607,8 @@ xs_str *html_notifications(snac *user, int skip, int show)
                 xs_html_text(L("None"))));
                 xs_html_text(L("None"))));
 
 
     /* add the navigation footer */
     /* add the navigation footer */
-    xs *next_p = notify_list(user, skip + show, 1);
+    xs *next_p = notify_filter_list(user, n_list_unfilt, skip + show, 1);
+
     if (xs_list_len(next_p)) {
     if (xs_list_len(next_p)) {
         xs *url = xs_fmt("%s/notifications?skip=%d&show=%d",
         xs *url = xs_fmt("%s/notifications?skip=%d&show=%d",
             user->actor, skip + show, show);
             user->actor, skip + show, show);

+ 1 - 1
snac.h

@@ -291,7 +291,7 @@ void notify_add(snac *snac, const char *type, const char *utype,
 xs_dict *notify_get(snac *snac, const char *id);
 xs_dict *notify_get(snac *snac, const char *id);
 int notify_new_num(snac *snac);
 int notify_new_num(snac *snac);
 xs_list *notify_list(snac *snac, int skip, int show);
 xs_list *notify_list(snac *snac, int skip, int show);
-xs_list *notify_filter_list(snac *snac, xs_list *ids);
+xs_list *notify_filter_list(snac *snac, xs_list *ids, int skip, int show);
 void notify_clear(snac *snac);
 void notify_clear(snac *snac);
 
 
 xs_dict *markers_get(snac *snac, const xs_list *markers);
 xs_dict *markers_get(snac *snac, const xs_list *markers);