aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2025-01-19 17:02:43 +0100
committerdefault <nobody@localhost>2025-01-19 17:02:43 +0100
commitba5d978bf1385647d0f696f4d4cb3e3dd1cc544d (patch)
tree7736be51df79aed308fc8b42a8d939b73e57c403
parent2ab9db4175cde75889bb43d0805d96759d6215bc (diff)
Update user config from admin/followed-hashtags.
-rw-r--r--html.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/html.c b/html.c
index 3ad330d..09dd202 100644
--- a/html.c
+++ b/html.c
@@ -1374,7 +1374,7 @@ xs_html *html_top_controls(snac *snac)
xs_html_attr("enctype", "multipart/form-data"),
xs_html_tag("textarea",
- xs_html_attr("name", "hashtags"),
+ xs_html_attr("name", "followed_hashtags"),
xs_html_attr("cols", "40"),
xs_html_attr("rows", "4"),
xs_html_attr("placeholder", "#cats\n#windowfriday\n#classicalmusic"),
@@ -4390,6 +4390,35 @@ int html_post_handler(const xs_dict *req, const char *q_path,
status = HTTP_STATUS_SEE_OTHER;
}
+ else
+ if (p_path && strcmp(p_path, "admin/followed-hashtags") == 0) { /** **/
+ const char *followed_hashtags = xs_dict_get(p_vars, "followed_hashtags");
+
+ if (xs_is_string(followed_hashtags)) {
+ xs *new_hashtags = xs_list_new();
+ xs *l = xs_split(followed_hashtags, "\n");
+ const char *v;
+
+ xs_list_foreach(l, v) {
+ xs *s1 = xs_strip_i(xs_dup(v));
+ s1 = xs_replace_i(s1, " ", "");
+
+ if (*s1 == '\0')
+ continue;
+
+ xs *s2 = xs_utf8_to_lower(s1);
+ if (*s2 != '#')
+ s2 = xs_str_prepend_i(s2, "#");
+
+ new_hashtags = xs_list_append(new_hashtags, s2);
+ }
+
+ snac.config = xs_dict_set(snac.config, "followed_hashtags", new_hashtags);
+ user_persist(&snac, 0);
+ }
+
+ status = HTTP_STATUS_SEE_OTHER;
+ }
if (status == HTTP_STATUS_SEE_OTHER) {
const char *redir = xs_dict_get(p_vars, "redir");