- public void handleCommand(final Namespace ns, final Signal signal) throws CommandException {
- final List<String> recipients = ns.getList("recipient");
- final var groupIdString = ns.getString("group");
+ public void handleCommand(
+ final Namespace ns, final Manager m, final OutputWriter outputWriter
+ ) throws CommandException {
+ final var isNoteToSelf = 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 long targetTimestamp = ns.getLong("target-timestamp");
+
+ try {
+ final var results = m.sendRemoteDeleteMessage(targetTimestamp, recipientIdentifiers);
+ outputResult(outputWriter, results.getTimestamp());
+ ErrorUtils.handleSendMessageResults(results.getResults());
+ } catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
+ throw new UserErrorException(e.getMessage());
+ } catch (IOException e) {
+ throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
+ .getSimpleName() + ")", e);
+ }
+ }
+
+ @Override
+ public void handleCommand(
+ final Namespace ns, final Signal signal, final OutputWriter outputWriter
+ ) throws CommandException {
+ final var recipients = ns.<String>getList("recipient");
+ final var groupIdStrings = ns.<String>getList("group-id");