fix an edge case where a config message might get isApproved set to false

This commit is contained in:
ryanzhao 2022-03-29 13:51:34 +11:00
parent 59f112c55f
commit 801f0d68a8
1 changed files with 8 additions and 2 deletions

View File

@ -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)