From 423ce97b4e51ddf3c9e827a6cfa34db33e4ff614 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 20 Nov 2023 20:10:14 +0100 Subject: [PATCH] Fix to delete user when unregister for notifications failed Whenever there was an error when unregistering from notifications, the user was not deleted. This could lead to multiple bugs. Furthermore, external signaling server connection and arbitrary storage is now always handled for user deletion, which was not the case before. Signed-off-by: Marcel Hibbe --- .../nextcloud/talk/jobs/AccountRemovalWorker.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java index 940d6780d0..51428fe5df 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java @@ -129,6 +129,7 @@ public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOvera @Override public void onError(@io.reactivex.annotations.NonNull Throwable e) { Log.e(TAG, "error while trying to unregister Device For Notifications", e); + initiateUserDeletion(user); } @Override @@ -137,7 +138,7 @@ public void onComplete() { } }); } else { - deleteUser(user); + initiateUserDeletion(user); } } @@ -172,15 +173,13 @@ public void onNext(Void aVoid) { } } - if (user.getId() != null) { - WebSocketConnectionHelper.deleteExternalSignalingInstanceForUserEntity(user.getId()); - } - deleteAllEntriesForAccountIdentifier(user); + initiateUserDeletion(user); } @Override public void onError(Throwable e) { Log.e(TAG, "error while trying to unregister Device For Notification With Proxy", e); + initiateUserDeletion(user); } @Override @@ -190,8 +189,10 @@ public void onComplete() { }); } - private void deleteAllEntriesForAccountIdentifier(User user) { + private void initiateUserDeletion(User user) { if (user.getId() != null) { + WebSocketConnectionHelper.deleteExternalSignalingInstanceForUserEntity(user.getId()); + try { arbitraryStorageManager.deleteAllEntriesForAccountIdentifier(user.getId()); deleteUser(user);