commit 85a9ebc

default  ·  2023-10-16 16:59:41 +0000 UTC
parent a38495b
Added web UI for setting the 'private' flag.
1 files changed,  +10, -0
M html.c
M html.c
+10, -0
 1@@ -607,6 +607,9 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
 2         "<p><input type=\"checkbox\" name=\"bot\" id=\"bot\" %s>\n"
 3         "<label for=\"bot\">%s</label></p>\n"
 4 
 5+        "<p><input type=\"checkbox\" name=\"private\" id=\"private\" %s>\n"
 6+        "<label for=\"private\">%s</label></p>\n"
 7+
 8         "<p>%s:<br>\n"
 9         "<textarea name=\"metadata\" cols=\"40\" rows=\"4\" "
10         "placeholder=\"Blog=https:/" "/example.com/my-blog\nGPG Key=1FA54\n...\">"
11@@ -659,6 +662,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
12     const char *d_dm_f_u = xs_dict_get(snac->config, "drop_dm_from_unknown");
13 
14     const char *bot = xs_dict_get(snac->config, "bot");
15+    const char *a_private = xs_dict_get(snac->config, "private");
16 
17     xs *es1 = encode_html(xs_dict_get(snac->config, "name"));
18     xs *es2 = encode_html(xs_dict_get(snac->config, "bio"));
19@@ -730,6 +734,8 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
20         L("Drop direct messages from people you don't follow"),
21         xs_type(bot) == XSTYPE_TRUE ? "checked" : "",
22         L("This account is a bot"),
23+        xs_type(a_private) == XSTYPE_TRUE ? "checked" : "",
24+        L("This account is private (posts are not shown through the web)"),
25 
26         L("Profile metadata (key=value pairs in each line)"),
27         metadata,
28@@ -2545,6 +2551,10 @@ int html_post_handler(const xs_dict *req, const char *q_path,
29             snac.config = xs_dict_set(snac.config, "bot", xs_stock_true);
30         else
31             snac.config = xs_dict_set(snac.config, "bot", xs_stock_false);
32+        if ((v = xs_dict_get(p_vars, "private")) != NULL && strcmp(v, "on") == 0)
33+            snac.config = xs_dict_set(snac.config, "private", xs_stock_true);
34+        else
35+            snac.config = xs_dict_set(snac.config, "private", xs_stock_false);
36         if ((v = xs_dict_get(p_vars, "metadata")) != NULL) {
37             /* split the metadata and store it as a dict */
38             xs_dict *md = xs_dict_new();