- public void handleCommand(final Namespace ns, final Signal signal) throws CommandException {
- final List<String> recipients = ns.getList("recipient");
- final var isEndSession = ns.getBoolean("endsession");
- final var groupIdString = ns.getString("group");
- final var isNoteToSelf = ns.getBoolean("note_to_self");
-
- final var noRecipients = recipients == null || recipients.isEmpty();
- if ((noRecipients && isEndSession) || (noRecipients && groupIdString == null && !isNoteToSelf)) {
- throw new UserErrorException("No recipients given");
- }
- if (!noRecipients && groupIdString != null) {
- throw new UserErrorException("You cannot specify recipients by phone number and groups at the same time");
- }
- if (!noRecipients && isNoteToSelf) {
- throw new UserErrorException(
- "You cannot specify recipients by phone number and not to self at the same time");
- }
-
+ public void handleCommand(
+ final Namespace ns, final Manager m, final OutputWriter outputWriter
+ ) throws CommandException {
+ final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
+ final var recipientStrings = ns.<String>getList("recipient");
+ final var groupIdStrings = ns.<String>getList("group-id");
+
+ final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
+ isNoteToSelf,
+ recipientStrings,
+ groupIdStrings);
+
+ final var isEndSession = Boolean.TRUE.equals(ns.getBoolean("end-session"));