commit 8e521cc

grunfink  ·  2026-08-30 14:46:38 +0000 UTC
parent 61ef7a8
Added notification filter for Webmentions.
2 files changed,  +7, -0
M data.c
M html.c
M data.c
+3, -0
 1@@ -3593,6 +3593,7 @@ xs_list *notify_filter_list(snac *snac, xs_list *notifs, int skip, int show)
 2     int n_folreq_on = xs_is_true(xs_dict_get_def(n_filter, "folreqs", n_def));
 3     int n_blocks_on = xs_is_true(xs_dict_get_def(n_filter, "blocks", n_def));
 4     int n_polls_on  = xs_is_true(xs_dict_get_def(n_filter, "polls", n_def));
 5+    int n_webmen_on  = xs_is_true(xs_dict_get_def(n_filter, "webmentions", n_def));
 6 
 7     const xs_str *v;
 8     xs_list *flt = xs_list_new();
 9@@ -3633,6 +3634,8 @@ xs_list *notify_filter_list(snac *snac, xs_list *notifs, int skip, int show)
10             continue;
11         if (strcmp(type, "Announce") == 0 && !n_ann_on)
12             continue;
13+        if (strcmp(type, "Webmention") == 0 && !n_webmen_on)
14+            continue;
15 
16         if (skip) {
17             skip--;
M html.c
+4, -0
 1@@ -4246,6 +4246,7 @@ void notify_filter(snac *user, const xs_dict *p_vars)
 2     int folreq_on = (v = xs_dict_get(p_vars, "folreqs_on")) ? strcmp(v, "on") == 0 : 0;
 3     int blocks_on = (v = xs_dict_get(p_vars, "blocks_on")) ? strcmp(v, "on") == 0 : 0;
 4     int polls_on  = (v = xs_dict_get(p_vars, "polls_on")) ? strcmp(v, "on") == 0 : 0;
 5+    int webmen_on  = (v = xs_dict_get(p_vars, "webmentions_on")) ? strcmp(v, "on") == 0 : 0;
 6     xs *filter = xs_dict_new();
 7     filter = xs_dict_set(filter, "likes", xs_stock(likes_on ? XSTYPE_TRUE : XSTYPE_FALSE));
 8     filter = xs_dict_set(filter, "reacts", xs_stock(reacts_on ? XSTYPE_TRUE : XSTYPE_FALSE));
 9@@ -4256,6 +4257,7 @@ void notify_filter(snac *user, const xs_dict *p_vars)
10     filter = xs_dict_set(filter, "folreqs", xs_stock(folreq_on ? XSTYPE_TRUE : XSTYPE_FALSE));
11     filter = xs_dict_set(filter, "blocks", xs_stock(blocks_on ? XSTYPE_TRUE : XSTYPE_FALSE));
12     filter = xs_dict_set(filter, "polls", xs_stock(polls_on ? XSTYPE_TRUE : XSTYPE_FALSE));
13+    filter = xs_dict_set(filter, "webmentions", xs_stock(webmen_on ? XSTYPE_TRUE : XSTYPE_FALSE));
14     user->config = xs_dict_set(user->config, "notify_filter", filter);
15     user->tz = xs_dict_get_def(user->config, "tz", "UTC"); // previous line invalidates user->tz
16 }
17@@ -4290,6 +4292,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
18     int n_folreq_on = xs_is_true(xs_dict_get_def(n_filter, "folreqs", n_def));
19     int n_blocks_on = xs_is_true(xs_dict_get_def(n_filter, "blocks", n_def));
20     int n_polls_on  = xs_is_true(xs_dict_get_def(n_filter, "polls", n_def));
21+    int n_webmen_on  = xs_is_true(xs_dict_get_def(n_filter, "webmentions", n_def));
22 
23     xs_html *html = xs_html_tag("html",
24         html_user_head(user, NULL, NULL),
25@@ -4316,6 +4319,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
26         html_checkbox("folreqs_on", L("Follow requests"), n_folreq_on),
27         html_checkbox("blocks_on", L("Blocks"), n_blocks_on),
28         html_checkbox("polls_on", L("Polls"), n_polls_on),
29+        html_checkbox("webmentions_on", L("Webmentions"), n_webmen_on),
30         xs_html_sctag("input",
31             xs_html_attr("type",     "submit"),
32             xs_html_attr("class",    "button"),