فهرست منبع

small: configurable poll limit

green 1 سال پیش
والد
کامیت
50129db64b
2فایلهای تغییر یافته به همراه9 افزوده شده و 1 حذف شده
  1. 4 0
      activitypub.c
  2. 5 1
      html.c

+ 4 - 0
activitypub.c

@@ -2322,8 +2322,12 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
 {
 {
     xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL);
     xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL);
     int max      = 8;
     int max      = 8;
+    const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options");
     xs_set seen;
     xs_set seen;
 
 
+    if (xs_type(max_options) == XSTYPE_NUMBER)
+        max = xs_number_get(max_options);
+
     msg = xs_dict_set(msg, "type", "Question");
     msg = xs_dict_set(msg, "type", "Question");
 
 
     /* make it non-editable */
     /* make it non-editable */

+ 5 - 1
html.c

@@ -778,13 +778,17 @@ xs_html *html_note(snac *user, const char *summary,
 
 
     /* add poll controls */
     /* add poll controls */
     if (poll) {
     if (poll) {
+        const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options");
+        xs *poll_limit_str = xs_dup(L("Poll options (one per line, up to 8):"));
+        poll_limit_str = xs_replace_i(poll_limit_str, "8", xs_number_str(max_options));
+
         xs_html_add(form,
         xs_html_add(form,
             xs_html_tag("p", NULL),
             xs_html_tag("p", NULL),
             xs_html_tag("details",
             xs_html_tag("details",
                 xs_html_tag("summary",
                 xs_html_tag("summary",
                     xs_html_text(L("Poll..."))),
                     xs_html_text(L("Poll..."))),
                 xs_html_tag("p",
                 xs_html_tag("p",
-                    xs_html_text(L("Poll options (one per line, up to 8):")),
+                    xs_html_text(poll_limit_str),
                     xs_html_sctag("br", NULL),
                     xs_html_sctag("br", NULL),
                     xs_html_tag("textarea",
                     xs_html_tag("textarea",
                         xs_html_attr("class",    "snac-textarea"),
                         xs_html_attr("class",    "snac-textarea"),