commit 50129db

green  ·  2025-04-12 19:56:23 +0000 UTC
parent c6b411a
small: configurable poll limit
2 files changed,  +9, -1
M html.c
+4, -0
 1@@ -2322,8 +2322,12 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
 2 {
 3     xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL);
 4     int max      = 8;
 5+    const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options");
 6     xs_set seen;
 7 
 8+    if (xs_type(max_options) == XSTYPE_NUMBER)
 9+        max = xs_number_get(max_options);
10+
11     msg = xs_dict_set(msg, "type", "Question");
12 
13     /* make it non-editable */
M html.c
+5, -1
 1@@ -778,13 +778,17 @@ xs_html *html_note(snac *user, const char *summary,
 2 
 3     /* add poll controls */
 4     if (poll) {
 5+        const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options");
 6+        xs *poll_limit_str = xs_dup(L("Poll options (one per line, up to 8):"));
 7+        poll_limit_str = xs_replace_i(poll_limit_str, "8", xs_number_str(max_options));
 8+
 9         xs_html_add(form,
10             xs_html_tag("p", NULL),
11             xs_html_tag("details",
12                 xs_html_tag("summary",
13                     xs_html_text(L("Poll..."))),
14                 xs_html_tag("p",
15-                    xs_html_text(L("Poll options (one per line, up to 8):")),
16+                    xs_html_text(poll_limit_str),
17                     xs_html_sctag("br", NULL),
18                     xs_html_tag("textarea",
19                         xs_html_attr("class",    "snac-textarea"),