enforce poll choices are between 2 and 10

This commit is contained in:
Zachary Johnson 2026-03-02 22:52:19 -05:00 committed by Sebastian Scheibner
parent af56a28b94
commit 37b8a4a996
2 changed files with 5 additions and 0 deletions

View File

@ -442,6 +442,7 @@ By default, recipients can select multiple options.
*-o* OPTION [OPTION ...], *--option* OPTION [OPTION ...]*::
The options for the poll.
Between 2 and 10 options must be specified.
=== sendPollVote

View File

@ -24,6 +24,7 @@ import static org.asamk.signal.util.SendMessageResultUtils.outputResult;
public class SendPollCreateCommand implements JsonRpcLocalCommand {
private static final Logger logger = LoggerFactory.getLogger(SendPollCreateCommand.class);
private static final int MAX_POLL_OPTIONS = 10;
@Override
public String getName() {
@ -72,6 +73,9 @@ public class SendPollCreateCommand implements JsonRpcLocalCommand {
if (options.size() < 2) {
throw new UserErrorException("Poll needs at least two options");
}
if (options.size() > MAX_POLL_OPTIONS) {
throw new UserErrorException("Poll cannot have more than " + MAX_POLL_OPTIONS + " options");
}
try {
var results = m.sendPollCreateMessage(question, !noMulti, options, recipientIdentifiers, notifySelf);