From 618d892ae7a4b31eeb69bc2a6a5db3a866bf0c7f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 29 Sep 2019 01:40:40 +0200 Subject: [PATCH] account deletion: only attempt to delete omemo id when connected --- .../services/XmppConnectionService.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index cacb1404e..a5348e4e3 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2198,19 +2198,24 @@ public class XmppConnectionService extends Service { } public void deleteAccount(final Account account) { + final boolean connected = account.getStatus() == Account.State.ONLINE; synchronized (this.conversations) { - account.getAxolotlService().deleteOmemoIdentity(); - for (final Conversation conversation : conversations) { - if (conversation.getAccount() == account) { - if (conversation.getMode() == Conversation.MODE_MULTI) { - leaveMuc(conversation); - } - conversations.remove(conversation); - mNotificationService.clear(conversation); - } - } + if (connected) { + account.getAxolotlService().deleteOmemoIdentity(); + } + for (final Conversation conversation : conversations) { + if (conversation.getAccount() == account) { + if (conversation.getMode() == Conversation.MODE_MULTI) { + if (connected) { + leaveMuc(conversation); + } + } + conversations.remove(conversation); + mNotificationService.clear(conversation); + } + } if (account.getXmppConnection() != null) { - new Thread(() -> disconnect(account, false)).start(); + new Thread(() -> disconnect(account, !connected)).start(); } final Runnable runnable = () -> { if (!databaseBackend.deleteAccount(account)) {