commit b51c8f1
green
·
2026-03-17 15:09:19 +0000 UTC
parent f1bdb50
fix: memory errors in byte's notification filter
1 files changed,
+7,
-3
M
html.c
M
html.c
+7,
-3
1@@ -4111,7 +4111,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- xs_dict *filter = xs_dict_new();
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 filter = xs_dict_set(filter, "mentions", xs_stock(ments_on ? XSTYPE_TRUE : XSTYPE_FALSE));
10@@ -4122,6 +4122,7 @@ void notify_filter(snac *user, const xs_dict *p_vars)
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 user->config = xs_dict_set(user->config, "notify_filter", filter);
14+ user->tz = xs_dict_get_def(user->config, "tz", "UTC"); // previous line invalidates user->tz
15 }
16
17 xs_str *html_notifications(snac *user, int skip, int show)
18@@ -4137,7 +4138,9 @@ xs_str *html_notifications(snac *user, int skip, int show)
19 xs_html *body = html_user_body(user, 0);
20 const xs_dict *n_filter = xs_dict_get(user->config, "notify_filter");
21 if (!n_filter) {
22- user->config = xs_dict_set(user->config, "notify_filter", xs_dict_new());
23+ xs *filter = xs_dict_new();
24+ user->config = xs_dict_set(user->config, "notify_filter", filter);
25+ user->tz = xs_dict_get_def(user->config, "tz", "UTC"); // previous line invalidates user->tz
26 n_filter = xs_dict_get(user->config, "notify_filter");
27 }
28 xs *n_list = notify_filter_list(user, n_list_unfilt);
29@@ -4158,6 +4161,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
30 body);
31
32 xs *filter_notifs_action = xs_fmt("%s/admin/filter-notifications", user->actor);
33+ xs *notifs_action = xs_fmt("%s/notifications", user->actor);
34 xs_html *notifs_form = xs_html_tag("form",
35 xs_html_attr("autocomplete", "off"),
36 xs_html_attr("method", "post"),
37@@ -4167,7 +4171,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
38 xs_html_sctag("input",
39 xs_html_attr("type", "hidden"),
40 xs_html_attr("name", "hard-redir"),
41- xs_html_attr("value", xs_fmt("%s/notifications", user->actor))),
42+ xs_html_attr("value", notifs_action)),
43 html_checkbox("likes_on", L("Likes"), n_likes_on),
44 html_checkbox("reacts_on", L("Emoji reacts"), n_reacts_on),
45 html_checkbox("mentions_on", L("Mentions"), n_ments_on),