]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/JoinGroupCommand.java
Use Java 17
[signal-cli] / src / main / java / org / asamk / signal / commands / JoinGroupCommand.java
index 8d651592ee57782426b3500fea0a0c0977849ff9..892879f6c01f4757f9f52a07b16b6ea2fbfee10c 100644 (file)
@@ -55,16 +55,15 @@ public class JoinGroupCommand implements JsonRpcLocalCommand {
         try {
             final var results = m.joinGroup(linkUrl);
             var newGroupId = results.first();
-            if (outputWriter instanceof JsonWriter) {
-                final var writer = (JsonWriter) outputWriter;
-                if (!m.getGroup(newGroupId).isMember(m.getSelfRecipientId())) {
+            if (outputWriter instanceof JsonWriter writer) {
+                if (!m.getGroup(newGroupId).isMember()) {
                     writer.write(Map.of("groupId", newGroupId.toBase64(), "onlyRequested", true));
                 } else {
                     writer.write(Map.of("groupId", newGroupId.toBase64()));
                 }
             } else {
                 final var writer = (PlainTextWriter) outputWriter;
-                if (!m.getGroup(newGroupId).isMember(m.getSelfRecipientId())) {
+                if (!m.getGroup(newGroupId).isMember()) {
                     writer.println("Requested to join group \"{}\"", newGroupId.toBase64());
                 } else {
                     writer.println("Joined group \"{}\"", newGroupId.toBase64());
@@ -74,9 +73,14 @@ public class JoinGroupCommand implements JsonRpcLocalCommand {
         } catch (GroupPatchNotAcceptedException e) {
             throw new UserErrorException("Failed to join group, maybe already a member");
         } 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 (DBusExecutionException e) {
-            throw new UnexpectedErrorException("Failed to send message: " + e.getMessage());
+            throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
+                    .getSimpleName() + ")", e);
         } catch (GroupLinkNotActiveException e) {
             throw new UserErrorException("Group link is not valid: " + e.getMessage());
         }