Ver código fonte

Added notification filter for Webmentions.

grunfink 2 semanas atrás
pai
commit
8e521cce1f
2 arquivos alterados com 7 adições e 0 exclusões
  1. 3 0
      data.c
  2. 4 0
      html.c

+ 3 - 0
data.c

@@ -3593,6 +3593,7 @@ xs_list *notify_filter_list(snac *snac, xs_list *notifs, int skip, int show)
     int n_folreq_on = xs_is_true(xs_dict_get_def(n_filter, "folreqs", n_def));
     int n_blocks_on = xs_is_true(xs_dict_get_def(n_filter, "blocks", n_def));
     int n_polls_on  = xs_is_true(xs_dict_get_def(n_filter, "polls", n_def));
+    int n_webmen_on  = xs_is_true(xs_dict_get_def(n_filter, "webmentions", n_def));
 
     const xs_str *v;
     xs_list *flt = xs_list_new();
@@ -3633,6 +3634,8 @@ xs_list *notify_filter_list(snac *snac, xs_list *notifs, int skip, int show)
             continue;
         if (strcmp(type, "Announce") == 0 && !n_ann_on)
             continue;
+        if (strcmp(type, "Webmention") == 0 && !n_webmen_on)
+            continue;
 
         if (skip) {
             skip--;

+ 4 - 0
html.c

@@ -4246,6 +4246,7 @@ void notify_filter(snac *user, const xs_dict *p_vars)
     int folreq_on = (v = xs_dict_get(p_vars, "folreqs_on")) ? strcmp(v, "on") == 0 : 0;
     int blocks_on = (v = xs_dict_get(p_vars, "blocks_on")) ? strcmp(v, "on") == 0 : 0;
     int polls_on  = (v = xs_dict_get(p_vars, "polls_on")) ? strcmp(v, "on") == 0 : 0;
+    int webmen_on  = (v = xs_dict_get(p_vars, "webmentions_on")) ? strcmp(v, "on") == 0 : 0;
     xs *filter = xs_dict_new();
     filter = xs_dict_set(filter, "likes", xs_stock(likes_on ? XSTYPE_TRUE : XSTYPE_FALSE));
     filter = xs_dict_set(filter, "reacts", xs_stock(reacts_on ? XSTYPE_TRUE : XSTYPE_FALSE));
@@ -4256,6 +4257,7 @@ void notify_filter(snac *user, const xs_dict *p_vars)
     filter = xs_dict_set(filter, "folreqs", xs_stock(folreq_on ? XSTYPE_TRUE : XSTYPE_FALSE));
     filter = xs_dict_set(filter, "blocks", xs_stock(blocks_on ? XSTYPE_TRUE : XSTYPE_FALSE));
     filter = xs_dict_set(filter, "polls", xs_stock(polls_on ? XSTYPE_TRUE : XSTYPE_FALSE));
+    filter = xs_dict_set(filter, "webmentions", xs_stock(webmen_on ? XSTYPE_TRUE : XSTYPE_FALSE));
     user->config = xs_dict_set(user->config, "notify_filter", filter);
     user->tz = xs_dict_get_def(user->config, "tz", "UTC"); // previous line invalidates user->tz
 }
@@ -4290,6 +4292,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
     int n_folreq_on = xs_is_true(xs_dict_get_def(n_filter, "folreqs", n_def));
     int n_blocks_on = xs_is_true(xs_dict_get_def(n_filter, "blocks", n_def));
     int n_polls_on  = xs_is_true(xs_dict_get_def(n_filter, "polls", n_def));
+    int n_webmen_on  = xs_is_true(xs_dict_get_def(n_filter, "webmentions", n_def));
 
     xs_html *html = xs_html_tag("html",
         html_user_head(user, NULL, NULL),
@@ -4316,6 +4319,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
         html_checkbox("folreqs_on", L("Follow requests"), n_folreq_on),
         html_checkbox("blocks_on", L("Blocks"), n_blocks_on),
         html_checkbox("polls_on", L("Polls"), n_polls_on),
+        html_checkbox("webmentions_on", L("Webmentions"), n_webmen_on),
         xs_html_sctag("input",
             xs_html_attr("type",     "submit"),
             xs_html_attr("class",    "button"),