summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-05-24 13:00:52 +0200
committerdefault <nobody@localhost>2023-05-24 13:00:52 +0200
commit07b9fa90b20aff96a12cf7a4f3bf8158251b8164 (patch)
tree321f0782423eb56560b9c8869006343204fa9528 /html.c
parent67b21a9ecd23d0c26752870ae607b26084af065c (diff)
Polls can now be voted.
Diffstat (limited to 'html.c')
-rw-r--r--html.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/html.c b/html.c
index 56b0dee..e06a82f 100644
--- a/html.c
+++ b/html.c
@@ -920,8 +920,9 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
else {
/* poll still active */
xs *s1 = xs_fmt("<form method=\"post\" action=\"%s/admin/vote\">\n"
+ "<input type=\"hidden\" name=\"actor\" value= \"%s\">\n"
"<input type=\"hidden\" name=\"irt\" value=\"%s\">\n",
- snac->actor, id);
+ snac->actor, actor, id);
while (xs_list_iter(&p, &v)) {
const char *name = xs_dict_get(v, "name");
@@ -1954,6 +1955,25 @@ int html_post_handler(const xs_dict *req, const char *q_path,
status = 303;
}
+ else
+ if (p_path && strcmp(p_path, "admin/vote") == 0) { /** **/
+ char *irt = xs_dict_get(p_vars, "irt");
+ const char *opt = xs_dict_get(p_vars, "question");
+ const char *actor = xs_dict_get(p_vars, "actor");
+
+ xs *msg = msg_note(&snac, "", actor, irt, NULL, 1);
+
+ /* set the option */
+ msg = xs_dict_append(msg, "name", opt);
+
+ xs *c_msg = msg_create(&snac, msg);
+
+ enqueue_message(&snac, c_msg);
+
+ timeline_add(&snac, xs_dict_get(msg, "id"), msg);
+
+ status = 303;
+ }
if (status == 303) {
char *redir = xs_dict_get(p_vars, "redir");