commit 7eef1b4

default  ·  2023-09-06 11:50:02 +0000 UTC
parent 4883bbe
Added new buttons to Follow/Unfollow Groups.
1 files changed,  +17, -3
M html.c
M html.c
+17, -3
 1@@ -760,8 +760,10 @@ xs_str *build_mentions(snac *snac, const xs_dict *msg)
 2 
 3 xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const char *md5)
 4 {
 5-    char *id    = xs_dict_get(msg, "id");
 6-    char *actor = xs_dict_get(msg, "attributedTo");
 7+    const char *id    = xs_dict_get(msg, "id");
 8+    const char *actor = xs_dict_get(msg, "attributedTo");
 9+    const char *group = xs_dict_get(msg, "audience");
10+
11     xs *likes   = object_likes(id);
12     xs *boosts  = object_announces(id);
13 
14@@ -774,10 +776,11 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch
15             "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n"
16             "<input type=\"hidden\" name=\"id\" value=\"%s\">\n"
17             "<input type=\"hidden\" name=\"actor\" value=\"%s\">\n"
18+            "<input type=\"hidden\" name=\"group\" value=\"%s\">\n"
19             "<input type=\"hidden\" name=\"redir\" value=\"%s_entry\">\n"
20             "\n",
21 
22-            snac->actor, id, actor, md5
23+            snac->actor, id, actor, group ? group : "", md5
24         );
25 
26         s = xs_str_cat(s, s1);
27@@ -812,6 +815,17 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch
28             s = html_button(s, "follow", L("Follow"), L("Start following this user's activity"));
29         }
30 
31+        if (!xs_is_null(group)) {
32+            if (following_check(snac, group)) {
33+                s = html_button(s, "unfollow", L("Unfollow Group"),
34+                        L("Stop following this group or channel"));
35+            }
36+            else {
37+                s = html_button(s, "follow", L("Follow Group"),
38+                        L("Start following this group or channel"));
39+            }
40+        }
41+
42         s = html_button(s, "mute", L("MUTE"),
43             L("Block any activity from this user forever"));
44     }