mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-09-21 06:19:41 +00:00
enforce poll choices are between 2 and 10
This commit is contained in:
parent
af56a28b94
commit
37b8a4a996
@ -442,6 +442,7 @@ By default, recipients can select multiple options.
|
|||||||
|
|
||||||
*-o* OPTION [OPTION ...], *--option* OPTION [OPTION ...]*::
|
*-o* OPTION [OPTION ...], *--option* OPTION [OPTION ...]*::
|
||||||
The options for the poll.
|
The options for the poll.
|
||||||
|
Between 2 and 10 options must be specified.
|
||||||
|
|
||||||
=== sendPollVote
|
=== sendPollVote
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import static org.asamk.signal.util.SendMessageResultUtils.outputResult;
|
|||||||
public class SendPollCreateCommand implements JsonRpcLocalCommand {
|
public class SendPollCreateCommand implements JsonRpcLocalCommand {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SendPollCreateCommand.class);
|
private static final Logger logger = LoggerFactory.getLogger(SendPollCreateCommand.class);
|
||||||
|
private static final int MAX_POLL_OPTIONS = 10;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -72,6 +73,9 @@ public class SendPollCreateCommand implements JsonRpcLocalCommand {
|
|||||||
if (options.size() < 2) {
|
if (options.size() < 2) {
|
||||||
throw new UserErrorException("Poll needs at least two options");
|
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 {
|
try {
|
||||||
var results = m.sendPollCreateMessage(question, !noMulti, options, recipientIdentifiers, notifySelf);
|
var results = m.sendPollCreateMessage(question, !noMulti, options, recipientIdentifiers, notifySelf);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user