From 203d793cf08c6a3a1835bad3b6e344bce3a49e1c Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:05:40 +0400 Subject: [PATCH] filter on contact deletion --- src/Simplex/Chat/Store/Direct.hs | 4 ++-- src/Simplex/Chat/Store/Groups.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat/Store/Direct.hs b/src/Simplex/Chat/Store/Direct.hs index 43d58d3ffa..43de2f2dc5 100644 --- a/src/Simplex/Chat/Store/Direct.hs +++ b/src/Simplex/Chat/Store/Direct.hs @@ -240,7 +240,7 @@ deleteContact db user@User {userId} Contact {contactId, localDisplayName, active else do currentTs <- getCurrentTime DB.execute db "UPDATE group_members SET contact_id = NULL, updated_at = ? WHERE user_id = ? AND contact_id = ?" (currentTs, userId, contactId) - DB.execute db "DELETE FROM contacts WHERE user_id = ? AND contact_id = ?" (userId, contactId) + DB.execute db "DELETE FROM contacts WHERE user_id = ? AND contact_id = ? AND is_user = 0" (userId, contactId) forM_ activeConn $ \Connection {customUserProfileId} -> forM_ customUserProfileId $ \profileId -> deleteUnusedIncognitoProfileById_ db user profileId @@ -251,7 +251,7 @@ deleteContactWithoutGroups db user@User {userId} Contact {contactId, localDispla DB.execute db "DELETE FROM chat_items WHERE user_id = ? AND contact_id = ?" (userId, contactId) deleteContactProfile_ db userId contactId DB.execute db "DELETE FROM display_names WHERE user_id = ? AND local_display_name = ?" (userId, localDisplayName) - DB.execute db "DELETE FROM contacts WHERE user_id = ? AND contact_id = ?" (userId, contactId) + DB.execute db "DELETE FROM contacts WHERE user_id = ? AND contact_id = ? AND is_user = 0" (userId, contactId) forM_ activeConn $ \Connection {customUserProfileId} -> forM_ customUserProfileId $ \profileId -> deleteUnusedIncognitoProfileById_ db user profileId diff --git a/src/Simplex/Chat/Store/Groups.hs b/src/Simplex/Chat/Store/Groups.hs index 102e26e830..985d672426 100644 --- a/src/Simplex/Chat/Store/Groups.hs +++ b/src/Simplex/Chat/Store/Groups.hs @@ -1656,7 +1656,7 @@ mergeContactRecords db user@User {userId} to@Contact {localDisplayName = keepLDN ":updated_at" := currentTs ] deleteContactProfile_ db userId fromContactId - DB.execute db "DELETE FROM contacts WHERE contact_id = ? AND user_id = ?" (fromContactId, userId) + DB.execute db "DELETE FROM contacts WHERE contact_id = ? AND user_id = ? AND is_user = 0" (fromContactId, userId) deleteUnusedDisplayName_ db userId fromLDN when (keepLDN /= toLDN && keepLDN == fromLDN) $ DB.execute