commit 07b9fa9
default
·
2023-05-24 11:00:52 +0000 UTC
parent 67b21a9
Polls can now be voted.
1 files changed,
+21,
-1
M
html.c
M
html.c
+21,
-1
1@@ -920,8 +920,9 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
2 else {
3 /* poll still active */
4 xs *s1 = xs_fmt("<form method=\"post\" action=\"%s/admin/vote\">\n"
5+ "<input type=\"hidden\" name=\"actor\" value= \"%s\">\n"
6 "<input type=\"hidden\" name=\"irt\" value=\"%s\">\n",
7- snac->actor, id);
8+ snac->actor, actor, id);
9
10 while (xs_list_iter(&p, &v)) {
11 const char *name = xs_dict_get(v, "name");
12@@ -1954,6 +1955,25 @@ int html_post_handler(const xs_dict *req, const char *q_path,
13
14 status = 303;
15 }
16+ else
17+ if (p_path && strcmp(p_path, "admin/vote") == 0) { /** **/
18+ char *irt = xs_dict_get(p_vars, "irt");
19+ const char *opt = xs_dict_get(p_vars, "question");
20+ const char *actor = xs_dict_get(p_vars, "actor");
21+
22+ xs *msg = msg_note(&snac, "", actor, irt, NULL, 1);
23+
24+ /* set the option */
25+ msg = xs_dict_append(msg, "name", opt);
26+
27+ xs *c_msg = msg_create(&snac, msg);
28+
29+ enqueue_message(&snac, c_msg);
30+
31+ timeline_add(&snac, xs_dict_get(msg, "id"), msg);
32+
33+ status = 303;
34+ }
35
36 if (status == 303) {
37 char *redir = xs_dict_get(p_vars, "redir");