From 801f0d68a88f9a35a134cd72801ae1eb6944385a Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 29 Mar 2022 13:51:34 +1100 Subject: [PATCH] fix an edge case where a config message might get isApproved set to false --- .../Sending & Receiving/MessageReceiver+Handling.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift index cfc213582..8b4acf3ae 100644 --- a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift +++ b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift @@ -219,9 +219,15 @@ extension MessageReceiver { // Note: We only update these values if the proto actually has values for them (this is to // prevent an edge case where an old client could override the values with default values // since they aren't included) - if contactInfo.hasIsApproved { contact.isApproved = contactInfo.isApproved } + // + // Note: Since message requests has no reverse, the only case we need to process is a + // config message setting *isApproved* and *didApproveMe* to true. This may prevent some + // weird edge cases where a config message swapping *isApproved* and *didApproveMe* to + // false. + if contactInfo.hasIsApproved && contactInfo.isApproved { contact.isApproved = true } + if contactInfo.hasDidApproveMe && contactInfo.didApproveMe { contact.didApproveMe = true } + if contactInfo.hasIsBlocked { contact.isBlocked = contactInfo.isBlocked } - if contactInfo.hasDidApproveMe { contact.didApproveMe = contactInfo.didApproveMe } Storage.shared.setContact(contact, using: transaction)