From 2445cda3e0c680962c285bd6e904ceb67968da3f Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 26 Feb 2024 12:49:04 -0500 Subject: [PATCH] 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. --- protocol/messenger_contacts.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/protocol/messenger_contacts.go b/protocol/messenger_contacts.go index 2d7d23550..2ef494eab 100644 --- a/protocol/messenger_contacts.go +++ b/protocol/messenger_contacts.go @@ -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)