From 50129db64b70604d347c2f21be5e5182080c6e07 Mon Sep 17 00:00:00 2001 From: green Date: Sat, 12 Apr 2025 21:56:23 +0200 Subject: small: configurable poll limit --- activitypub.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index c34e510..2890a94 100644 --- a/activitypub.c +++ b/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); int max = 8; + const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options"); xs_set seen; + if (xs_type(max_options) == XSTYPE_NUMBER) + max = xs_number_get(max_options); + msg = xs_dict_set(msg, "type", "Question"); /* make it non-editable */ -- cgit v1.2.3 From ce8e11adc74015931d9adac6f3b108e7ec31fbf5 Mon Sep 17 00:00:00 2001 From: green Date: Mon, 5 May 2025 22:52:50 +0200 Subject: personal: bigger limit for polls --- activitypub.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 2890a94..8964030 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2321,6 +2321,7 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach, /* creates a Question message */ { xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL); + int max_line = 200; int max = 8; const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options"); xs_set seen; @@ -2345,8 +2346,8 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach, xs *v2 = xs_dup(v); xs *d = xs_dict_new(); - if (strlen(v2) > 60) { - v2[60] = '\0'; + if (strlen(v2) > max_line) { + v2[max_line] = '\0'; v2 = xs_str_cat(v2, "..."); } -- cgit v1.2.3 From cc013a5af8a661a954a15bf46a2feb17d8574855 Mon Sep 17 00:00:00 2001 From: green Date: Sat, 24 Jan 2026 02:14:18 +0100 Subject: poll-limit: fix warning --- activitypub.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 8964030..e9e28be 100644 --- a/activitypub.c +++ b/activitypub.c @@ -17,6 +17,7 @@ #include "snac.h" +#include #include const char * const public_address = "https:/" "/www.w3.org/ns/activitystreams#Public"; @@ -2321,8 +2322,8 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach, /* creates a Question message */ { xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL); - int max_line = 200; - int max = 8; + size_t max_line = 200; + int max = 8; const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options"); xs_set seen; -- cgit v1.2.3 From cd96b83828a852bdf4f4311900501eba8c3972ca Mon Sep 17 00:00:00 2001 From: green Date: Sat, 24 Jan 2026 23:37:55 +0100 Subject: poll-limits: added "max_poll_option_length" option --- activitypub.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index e9e28be..8eb7844 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2322,13 +2322,16 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach, /* creates a Question message */ { xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL); - size_t max_line = 200; - int max = 8; const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options"); + const xs_number *max_length = xs_dict_get(srv_config, "max_poll_option_length"); xs_set seen; + size_t max_line = 60; + int max = 8; if (xs_type(max_options) == XSTYPE_NUMBER) max = xs_number_get(max_options); + if (xs_type(max_length) == XSTYPE_NUMBER) + max_line = xs_number_get(max_length); msg = xs_dict_set(msg, "type", "Question"); -- cgit v1.2.3