mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
Polls can now be voted.
This commit is contained in:
parent
67b21a9ecd
commit
07b9fa90b2
1 changed files with 21 additions and 1 deletions
22
html.c
22
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");
|
||||
|
|
Loading…
Reference in a new issue