diff --git a/protocol/messenger.go b/protocol/messenger.go index 23fb3a49a..15037f958 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -1263,11 +1263,19 @@ func (m *Messenger) BlockContact(contact *Contact) ([]*Chat, error) { if err != nil { return nil, err } + m.allContacts[contact.ID] = contact for _, chat := range chats { m.allChats[chat.ID] = chat } delete(m.allChats, contact.ID) + + // re-register for push notifications + err = m.reregisterForPushNotifications() + if err != nil { + return nil, err + } + return chats, nil } @@ -1562,6 +1570,12 @@ func (m *Messenger) SendContactUpdates(ctx context.Context, ensName, profileImag return nil } +// NOTE: this endpoint does not add the contact, the reason being is that currently +// that's left as a responsibility to the client, which will call both `SendContactUpdate` +// and `SaveContact` with the correct system tag. +// Ideally we have a single endpoint that does both, but probably best to bring `ENS` name +// on the messenger first. + // SendContactUpdate sends a contact update to a user and adds the user to contacts func (m *Messenger) SendContactUpdate(ctx context.Context, chatID, ensName, profileImage string) (*MessengerResponse, error) { m.mutex.Lock() @@ -1623,10 +1637,6 @@ func (m *Messenger) sendContactUpdate(ctx context.Context, chatID, ensName, prof return nil, err } - if !contact.IsAdded() && contact.ID != contactIDFromPublicKey(&m.identity.PublicKey) { - contact.SystemTags = append(contact.SystemTags, contactAdded) - } - response.Contacts = []*Contact{contact} response.Chats = []*Chat{chat} diff --git a/protocol/messenger_contact_update_test.go b/protocol/messenger_contact_update_test.go index c89a7f645..b54f8360d 100644 --- a/protocol/messenger_contact_update_test.go +++ b/protocol/messenger_contact_update_test.go @@ -99,7 +99,12 @@ func (s *MessengerContactUpdateSuite) TestReceiveContactUpdate() { s.Require().Len(response.Contacts, 1) contact := response.Contacts[0] - s.Require().True(contact.IsAdded()) + // It should not add the contact, as that's left to `SaveContact` + s.Require().False(contact.IsAdded()) + + // add contact + contact.SystemTags = []string{contactAdded} + s.Require().NoError(theirMessenger.SaveContact(contact)) s.Require().Len(response.Chats, 1) chat := response.Chats[0]