From c2ea7045f5e92610f5f5d6cd62d064a7944a41cf Mon Sep 17 00:00:00 2001 From: AsamK Date: Mon, 9 Oct 2023 19:08:32 +0200 Subject: [PATCH] Prevent deleting self recipient --- .../java/org/asamk/signal/manager/storage/SignalAccount.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java b/lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java index 2d1956fe..4092bd79 100644 --- a/lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java +++ b/lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java @@ -424,6 +424,9 @@ public class SignalAccount implements Closeable { 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()) {