fix(contacts): fix blocking a non-contact sends a signal to the other (#4799)

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

The code is correct in sending an updated CR to make sure the sync doesn't sync back the previous state or at least overrides it.
However, if we never were a contact with the person sending us a CR, and we block them, it sends them a "you got removed" message, which first doesn't make sense but also could let them know they got blocked/ignored.
The trick is just to make sure we added them first. Then dismissing the CR makes sense.
This commit is contained in:
Jonathan Rainville 2024-02-26 12:49:04 -05:00 committed by GitHub
parent fbb89cb13f
commit 2445cda3e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -854,6 +854,7 @@ func (m *Messenger) blockContact(ctx context.Context, response *MessengerRespons
return err
}
contactWasAdded := contact.added()
contact.Block(clock)
contact.LastUpdatedLocally = m.getTimesource().GetCurrentTime()
@ -876,9 +877,11 @@ func (m *Messenger) blockContact(ctx context.Context, response *MessengerRespons
}
if !fromSyncing {
err = m.sendRetractContactRequest(contact)
if err != nil {
return err
if contactWasAdded {
err = m.sendRetractContactRequest(contact)
if err != nil {
return err
}
}
err = m.syncContact(context.Background(), contact, m.dispatchMessage)