commit f1f3e3b

default  ·  2023-02-20 05:00:54 +0000 UTC
parent a3804c2
Email notifications can be disabled.
2 files changed,  +23, -5
M html.c
+12, -2
 1@@ -838,9 +838,19 @@ void notify(snac *snac, xs_str *type, xs_str *utype, xs_str *actor, xs_dict *msg
 2 
 3     /* email */
 4 
 5-    char *email = xs_dict_get(snac->config, "email");
 6+    const char *email = "[disabled by admin]";
 7 
 8-    if (!xs_is_null(email) && *email != '\0') {
 9+    if (xs_type(xs_dict_get(srv_config, "disable_email_notifications")) != XSTYPE_TRUE) {
10+        email = xs_dict_get(snac->config_o, "email");
11+        if (xs_is_null(email)) {
12+            email = xs_dict_get(snac->config, "email");
13+
14+            if (xs_is_null(email))
15+                email = "[empty]";
16+        }
17+    }
18+
19+    if (*email != '[') {
20         snac_debug(snac, 1, xs_fmt("email notify %s %s %s", type, utype, actor));
21 
22         xs *subject = xs_fmt("snac notify for @%s@%s",
M html.c
+11, -3
 1@@ -327,9 +327,17 @@ d_char *html_top_controls(snac *snac, d_char *s)
 2         "</div>\n"
 3         "</div>\n";
 4 
 5-    char *email = xs_dict_get(snac->config, "email");
 6-    if (xs_is_null(email))
 7-        email = "";
 8+    const char *email = "[disabled by admin]";
 9+
10+    if (xs_type(xs_dict_get(srv_config, "disable_email_notifications")) != XSTYPE_TRUE) {
11+        email = xs_dict_get(snac->config_o, "email");
12+        if (xs_is_null(email)) {
13+            email = xs_dict_get(snac->config, "email");
14+
15+            if (xs_is_null(email))
16+                email = "";
17+        }
18+    }
19 
20     char *cw = xs_dict_get(snac->config, "cw");
21     if (xs_is_null(cw))