fix(handler): fix CR received from a removed contact removed (#4708)

Fixes https://github.com/status-im/status-desktop/issues/13488

The problem was that when you add a contact, it create the chat. Then, if you remove them, it doesn't remove the chat, so `chat.Active` is true.
Now I check in that case if it's a 1x1 chat and if so, if we are contact.
This commit is contained in:
Jonathan Rainville 2024-02-13 10:15:42 -05:00 committed by GitHub
parent 5149976ce0
commit 2bdc7ec0f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 7 deletions

View File

@ -3159,18 +3159,23 @@ func (m *Messenger) isMessageAllowedFrom(publicKey string, chat *Chat) (bool, er
return true, nil
}
// If the chat is active, we allow it
if chat != nil && chat.Active {
return true, nil
}
// If the chat is public, we allow it
if chat != nil && chat.Public() {
return true, nil
}
contact, ok := m.allContacts.Load(publicKey)
if !ok {
contact, contactOk := m.allContacts.Load(publicKey)
// If the chat is active, we allow it
if chat != nil && chat.Active {
if contactOk {
// If the chat is active and it is a 1x1 chat, we need to make sure the contact is added and not removed
return contact.added(), nil
}
return true, nil
}
if !contactOk {
// If it's not in contacts, we don't allow it
return false, nil
}