]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java
Implement support for usernames
[signal-cli] / src / main / java / org / asamk / signal / dbus / DbusManagerImpl.java
index 0ccff7351415d8c12825cfd67c380c41d7af4886..cefb7a820f68a63030fbd5ff9ffba873c91e18b2 100644 (file)
@@ -10,6 +10,7 @@ import org.asamk.signal.manager.api.Group;
 import org.asamk.signal.manager.api.Identity;
 import org.asamk.signal.manager.api.InactiveGroupLinkException;
 import org.asamk.signal.manager.api.InvalidDeviceLinkException;
+import org.asamk.signal.manager.api.InvalidUsernameException;
 import org.asamk.signal.manager.api.Message;
 import org.asamk.signal.manager.api.MessageEnvelope;
 import org.asamk.signal.manager.api.NotPrimaryDeviceException;
@@ -151,6 +152,16 @@ public class DbusManagerImpl implements Manager {
                 updateProfile.isDeleteAvatar());
     }
 
+    @Override
+    public String setUsername(final String username) throws IOException, InvalidUsernameException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void deleteUsername() throws IOException {
+        throw new UnsupportedOperationException();
+    }
+
     @Override
     public void unregister() throws IOException {
         signal.unregister();
@@ -219,7 +230,15 @@ public class DbusManagerImpl implements Manager {
             throw new UnsupportedOperationException();
         }
         final var group = getRemoteObject(signal.getGroup(groupId.serialize()), Signal.Group.class);
-        group.quitGroup();
+        try {
+            group.quitGroup();
+        } catch (Signal.Error.GroupNotFound e) {
+            throw new GroupNotFoundException(groupId);
+        } catch (Signal.Error.NotAGroupMember e) {
+            throw new NotAGroupMemberException(groupId, group.Get("org.asamk.Signal.Group", "Name"));
+        } catch (Signal.Error.LastGroupAdmin e) {
+            throw new LastGroupAdminException(groupId, group.Get("org.asamk.Signal.Group", "Name"));
+        }
         return new SendGroupMessageResults(0, List.of());
     }