commit b3797d2

default  ·  2023-08-09 12:29:09 +0000 UTC
parent 3e5bb10
Implemented hide_followers_only.
1 files changed,  +16, -1
M html.c
M html.c
+16, -1
 1@@ -843,9 +843,10 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
 2     int sensitive = 0;
 3     char *v;
 4     xs *boosts = NULL;
 5+    int is_public = is_msg_public(snac, msg);
 6 
 7     /* do not show non-public messages in the public timeline */
 8-    if (local && !is_msg_public(snac, msg))
 9+    if (local && !is_public)
10         return os;
11 
12     /* hidden? do nothing more for this conversation */
13@@ -856,6 +857,20 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
14     if (level >= 256)
15         return os;
16 
17+    if (xs_type(xs_dict_get(snac->config, "hide_followers_only")) == XSTYPE_TRUE) {
18+        /* test if this is a non-public message not explicitly for this user */
19+        if (!is_public) {
20+            const char *to = xs_dict_get(msg, "to");
21+            const char *cc = xs_dict_get(msg, "cc");
22+
23+            if ((xs_is_null(to) || xs_list_in(to, snac->actor) == -1) &&
24+                (xs_is_null(cc) || xs_list_in(cc, snac->actor) == -1)) {
25+                snac_debug(snac, 0, xs_fmt("hidden message %s for followers only (%s)", id, md5));
26+                return os;
27+            }
28+        }
29+    }
30+
31     xs *s = xs_str_new("<div>\n");
32 
33     {