]> nmode's Git Repositories - signal-cli/commitdiff
Prevent deleting self recipient
authorAsamK <asamk@gmx.de>
Mon, 9 Oct 2023 17:08:32 +0000 (19:08 +0200)
committerAsamK <asamk@gmx.de>
Mon, 9 Oct 2023 17:13:45 +0000 (19:13 +0200)
lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java

index 2d1956feebec081985c7710927b0535725d8ccab..4092bd79918e0cb07c4152f075c2e542a4d0dd00 100644 (file)
@@ -424,6 +424,9 @@ public class SignalAccount implements Closeable {
 
     public void removeRecipient(final RecipientId recipientId) {
         final var recipientAddress = getRecipientStore().resolveRecipientAddress(recipientId);
 
     public void removeRecipient(final RecipientId recipientId) {
         final var recipientAddress = getRecipientStore().resolveRecipientAddress(recipientId);
+        if (recipientAddress.matches(getSelfRecipientAddress())) {
+            throw new RuntimeException("Can't delete self recipient");
+        }
         getRecipientStore().deleteRecipientData(recipientId);
         getMessageCache().deleteMessages(recipientId);
         if (recipientAddress.serviceId().isPresent()) {
         getRecipientStore().deleteRecipientData(recipientId);
         getMessageCache().deleteMessages(recipientId);
         if (recipientAddress.serviceId().isPresent()) {