commit ba5d978
default
·
2025-01-19 16:02:43 +0000 UTC
parent 2ab9db4
Update user config from admin/followed-hashtags.
1 files changed,
+30,
-1
M
html.c
M
html.c
+30,
-1
1@@ -1374,7 +1374,7 @@ xs_html *html_top_controls(snac *snac)
2 xs_html_attr("enctype", "multipart/form-data"),
3
4 xs_html_tag("textarea",
5- xs_html_attr("name", "hashtags"),
6+ xs_html_attr("name", "followed_hashtags"),
7 xs_html_attr("cols", "40"),
8 xs_html_attr("rows", "4"),
9 xs_html_attr("placeholder", "#cats\n#windowfriday\n#classicalmusic"),
10@@ -4390,6 +4390,35 @@ int html_post_handler(const xs_dict *req, const char *q_path,
11
12 status = HTTP_STATUS_SEE_OTHER;
13 }
14+ else
15+ if (p_path && strcmp(p_path, "admin/followed-hashtags") == 0) { /** **/
16+ const char *followed_hashtags = xs_dict_get(p_vars, "followed_hashtags");
17+
18+ if (xs_is_string(followed_hashtags)) {
19+ xs *new_hashtags = xs_list_new();
20+ xs *l = xs_split(followed_hashtags, "\n");
21+ const char *v;
22+
23+ xs_list_foreach(l, v) {
24+ xs *s1 = xs_strip_i(xs_dup(v));
25+ s1 = xs_replace_i(s1, " ", "");
26+
27+ if (*s1 == '\0')
28+ continue;
29+
30+ xs *s2 = xs_utf8_to_lower(s1);
31+ if (*s2 != '#')
32+ s2 = xs_str_prepend_i(s2, "#");
33+
34+ new_hashtags = xs_list_append(new_hashtags, s2);
35+ }
36+
37+ snac.config = xs_dict_set(snac.config, "followed_hashtags", new_hashtags);
38+ user_persist(&snac, 0);
39+ }
40+
41+ status = HTTP_STATUS_SEE_OTHER;
42+ }
43
44 if (status == HTTP_STATUS_SEE_OTHER) {
45 const char *redir = xs_dict_get(p_vars, "redir");