aboutsummaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorgrunfink <grunfink@noreply.codeberg.org>2026-01-25 10:20:35 +0100
committergrunfink <grunfink@noreply.codeberg.org>2026-01-25 10:20:35 +0100
commitd30472f0d96bc9e2659db1cfe55ecf439796b989 (patch)
treeabef499186bdd8d84741f5979fb6964ff31cfc02 /activitypub.c
parent27ca16011e4945ddc0d3e113840ace1a589011e1 (diff)
parenta14cf4a7dbbf6ee90ef8ff4974e7fe9a023d6e48 (diff)
Merge pull request 'Configurable limits for polls' (#534) from dandelions/snac2:poll-limits into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/534
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/activitypub.c b/activitypub.c
index c34e510..8eb7844 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -17,6 +17,7 @@
#include "snac.h"
+#include <stddef.h>
#include <sys/wait.h>
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,
/* creates a Question message */
{
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");
+ 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");
/* make it non-editable */
@@ -2341,8 +2350,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, "...");
}