diff options
| -rw-r--r-- | activitypub.c | 15 | ||||
| -rw-r--r-- | doc/snac.8 | 4 | ||||
| -rw-r--r-- | html.c | 15 |
3 files changed, 29 insertions, 5 deletions
diff --git a/activitypub.c b/activitypub.c index c34e510..8eb7844 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #include "snac.h" | 18 | #include "snac.h" |
| 19 | 19 | ||
| 20 | #include <stddef.h> | ||
| 20 | #include <sys/wait.h> | 21 | #include <sys/wait.h> |
| 21 | 22 | ||
| 22 | const char * const public_address = "https:/" "/www.w3.org/ns/activitystreams#Public"; | 23 | const char * const public_address = "https:/" "/www.w3.org/ns/activitystreams#Public"; |
| @@ -2321,9 +2322,17 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach, | |||
| 2321 | /* creates a Question message */ | 2322 | /* creates a Question message */ |
| 2322 | { | 2323 | { |
| 2323 | xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL); | 2324 | xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL); |
| 2324 | int max = 8; | 2325 | const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options"); |
| 2326 | const xs_number *max_length = xs_dict_get(srv_config, "max_poll_option_length"); | ||
| 2325 | xs_set seen; | 2327 | xs_set seen; |
| 2326 | 2328 | ||
| 2329 | size_t max_line = 60; | ||
| 2330 | int max = 8; | ||
| 2331 | if (xs_type(max_options) == XSTYPE_NUMBER) | ||
| 2332 | max = xs_number_get(max_options); | ||
| 2333 | if (xs_type(max_length) == XSTYPE_NUMBER) | ||
| 2334 | max_line = xs_number_get(max_length); | ||
| 2335 | |||
| 2327 | msg = xs_dict_set(msg, "type", "Question"); | 2336 | msg = xs_dict_set(msg, "type", "Question"); |
| 2328 | 2337 | ||
| 2329 | /* make it non-editable */ | 2338 | /* make it non-editable */ |
| @@ -2341,8 +2350,8 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach, | |||
| 2341 | xs *v2 = xs_dup(v); | 2350 | xs *v2 = xs_dup(v); |
| 2342 | xs *d = xs_dict_new(); | 2351 | xs *d = xs_dict_new(); |
| 2343 | 2352 | ||
| 2344 | if (strlen(v2) > 60) { | 2353 | if (strlen(v2) > max_line) { |
| 2345 | v2[60] = '\0'; | 2354 | v2[max_line] = '\0'; |
| 2346 | v2 = xs_str_cat(v2, "..."); | 2355 | v2 = xs_str_cat(v2, "..."); |
| 2347 | } | 2356 | } |
| 2348 | 2357 | ||
| @@ -269,6 +269,10 @@ The maximum number of entries (posts) to be returned in user RSS feeds and outbo | |||
| 269 | (default: 20). | 269 | (default: 20). |
| 270 | .It Ic max_attachments | 270 | .It Ic max_attachments |
| 271 | The maximum number of attachments per post (default: 4). | 271 | The maximum number of attachments per post (default: 4). |
| 272 | .It Ic max_poll_options | ||
| 273 | The maximum number of poll options in a poll (default: 8). | ||
| 274 | .It Ic max_poll_option_length | ||
| 275 | The maximum length of a single poll option (default: 60). | ||
| 272 | .It Ic enable_svg | 276 | .It Ic enable_svg |
| 273 | Since version 2.73, SVG image attachments are hidden by default; you can enable | 277 | Since version 2.73, SVG image attachments are hidden by default; you can enable |
| 274 | them by setting this value to true. | 278 | them by setting this value to true. |
| @@ -778,13 +778,18 @@ xs_html *html_note(snac *user, const char *summary, | |||
| 778 | 778 | ||
| 779 | /* add poll controls */ | 779 | /* add poll controls */ |
| 780 | if (poll) { | 780 | if (poll) { |
| 781 | const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options"); | ||
| 782 | xs *poll_limit_str = xs_dup(L("Poll options (one per line, up to 8):")); | ||
| 783 | if (max_options != NULL) | ||
| 784 | poll_limit_str = xs_replace_i(poll_limit_str, "8", xs_number_str(max_options)); | ||
| 785 | |||
| 781 | xs_html_add(form, | 786 | xs_html_add(form, |
| 782 | xs_html_tag("p", NULL), | 787 | xs_html_tag("p", NULL), |
| 783 | xs_html_tag("details", | 788 | xs_html_tag("details", |
| 784 | xs_html_tag("summary", | 789 | xs_html_tag("summary", |
| 785 | xs_html_text(L("Poll..."))), | 790 | xs_html_text(L("Poll..."))), |
| 786 | xs_html_tag("p", | 791 | xs_html_tag("p", |
| 787 | xs_html_text(L("Poll options (one per line, up to 8):")), | 792 | xs_html_text(poll_limit_str), |
| 788 | xs_html_sctag("br", NULL), | 793 | xs_html_sctag("br", NULL), |
| 789 | xs_html_tag("textarea", | 794 | xs_html_tag("textarea", |
| 790 | xs_html_attr("class", "snac-textarea"), | 795 | xs_html_attr("class", "snac-textarea"), |
| @@ -812,7 +817,13 @@ xs_html *html_note(snac *user, const char *summary, | |||
| 812 | xs_html_text(L("End in 1 hour"))), | 817 | xs_html_text(L("End in 1 hour"))), |
| 813 | xs_html_tag("option", | 818 | xs_html_tag("option", |
| 814 | xs_html_attr("value", "86400"), | 819 | xs_html_attr("value", "86400"), |
| 815 | xs_html_text(L("End in 1 day")))))); | 820 | xs_html_text(L("End in 1 day"))), |
| 821 | xs_html_tag("option", | ||
| 822 | xs_html_attr("value", "259200"), | ||
| 823 | xs_html_text(L("End in 3 days"))), | ||
| 824 | xs_html_tag("option", | ||
| 825 | xs_html_attr("value", "31536000"), | ||
| 826 | xs_html_text(L("End in 1 year")))))); | ||
| 816 | } | 827 | } |
| 817 | 828 | ||
| 818 | xs_html_add(form, | 829 | xs_html_add(form, |