summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-05-30 10:34:46 +0200
committerGravatar default2023-05-30 10:34:46 +0200
commit42918d44a0931ddf58eff863c9e21e93f051f229 (patch)
tree0c5e9c0fe6be09075f1260a8b08c24b463b10ce6
parentAdded a poll pull-down and options (still unused). (diff)
downloadsnac2-42918d44a0931ddf58eff863c9e21e93f051f229.tar.gz
snac2-42918d44a0931ddf58eff863c9e21e93f051f229.tar.xz
snac2-42918d44a0931ddf58eff863c9e21e93f051f229.zip
Create polls from the web interface.
-rw-r--r--html.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/html.c b/html.c
index 8c5aac7..38cdfe6 100644
--- a/html.c
+++ b/html.c
@@ -1769,8 +1769,31 @@ int html_post_handler(const xs_dict *req, const char *q_path,
1769 xs *msg = NULL; 1769 xs *msg = NULL;
1770 xs *c_msg = NULL; 1770 xs *c_msg = NULL;
1771 xs *content_2 = xs_replace(content, "\r", ""); 1771 xs *content_2 = xs_replace(content, "\r", "");
1772 xs *poll_opts = NULL;
1772 1773
1773 msg = msg_note(&snac, content_2, to, in_reply_to, attach_list, priv); 1774 /* is there a valid set of poll options? */
1775 const char *v = xs_dict_get(p_vars, "poll_options");
1776 if (!xs_is_null(v) && *v) {
1777 xs *v2 = xs_strip_i(xs_replace(v, "\r", ""));
1778
1779 poll_opts = xs_split(v2, "\n");
1780 }
1781
1782 if (!xs_is_null(poll_opts) && xs_list_len(poll_opts)) {
1783 /* get the rest of poll configuration */
1784 const char *p_multiple = xs_dict_get(p_vars, "poll_multiple");
1785 const char *p_end_secs = xs_dict_get(p_vars, "poll_end_secs");
1786
1787 int end_secs = atoi(!xs_is_null(p_end_secs) ? p_end_secs : "60");
1788 int multiple = !xs_is_null(p_multiple);
1789
1790 msg = msg_question(&snac, content_2, attach_list,
1791 poll_opts, multiple, end_secs);
1792
1793 enqueue_close_question(&snac, xs_dict_get(msg, "id"), end_secs);
1794 }
1795 else
1796 msg = msg_note(&snac, content_2, to, in_reply_to, attach_list, priv);
1774 1797
1775 if (sensitive != NULL) { 1798 if (sensitive != NULL) {
1776 xs *t = xs_val_new(XSTYPE_TRUE); 1799 xs *t = xs_val_new(XSTYPE_TRUE);