]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/QuitGroupCommand.java
Use Java 17
[signal-cli] / src / main / java / org / asamk / signal / commands / QuitGroupCommand.java
index 03bf232ba66aba3266554391b0dfe1e6fa892b88..8c3ac3bd206f70514a77364788aaa8d6dd27262e 100644 (file)
@@ -50,7 +50,7 @@ public class QuitGroupCommand implements JsonRpcLocalCommand {
     ) throws CommandException {
         final var groupId = CommandUtil.getGroupId(ns.getString("group-id"));
 
-        var groupAdmins = CommandUtil.getSingleRecipientIdentifiers(ns.getList("admin"), m.getUsername());
+        var groupAdmins = CommandUtil.getSingleRecipientIdentifiers(ns.getList("admin"), m.getSelfNumber());
 
         try {
             try {
@@ -61,12 +61,16 @@ public class QuitGroupCommand implements JsonRpcLocalCommand {
             } catch (NotAGroupMemberException e) {
                 logger.info("User is not a group member");
             }
-            if (ns.getBoolean("delete")) {
+            if (Boolean.TRUE.equals(ns.getBoolean("delete"))) {
                 logger.debug("Deleting group {}", groupId);
                 m.deleteGroup(groupId);
             }
         } catch (IOException e) {
-            throw new IOErrorException("Failed to send message: " + e.getMessage());
+            throw new IOErrorException("Failed to send message: "
+                    + e.getMessage()
+                    + " ("
+                    + e.getClass().getSimpleName()
+                    + ")", e);
         } catch (GroupNotFoundException e) {
             throw new UserErrorException("Failed to send to group: " + e.getMessage());
         } catch (LastGroupAdminException e) {
@@ -75,8 +79,7 @@ public class QuitGroupCommand implements JsonRpcLocalCommand {
     }
 
     private void outputResult(final OutputWriter outputWriter, final long timestamp) {
-        if (outputWriter instanceof PlainTextWriter) {
-            final var writer = (PlainTextWriter) outputWriter;
+        if (outputWriter instanceof PlainTextWriter writer) {
             writer.println("{}", timestamp);
         } else {
             final var writer = (JsonWriter) outputWriter;