Skip to content

Commit

Permalink
Fix syncing blocked contacts (#3799)
Browse files Browse the repository at this point in the history
* fix(messenger_testing_utils): Always return response
* feat: test blocking/unblocking contacts with paired devices 
* fix: Remove recursive sync on contact blocking
* rename `syncing` flag to `fromSyncing`
  • Loading branch information
igor-sirotin authored Aug 4, 2023
1 parent 3bd972d commit bbb8e99
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 86 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.162.14
0.163.1
8 changes: 4 additions & 4 deletions protocol/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (c *Contact) DismissContactRequest(clock uint64) ContactRequestProcessingRe

// Remote actions

func (c *Contact) contactRequestRetracted(clock uint64, syncing bool, r ContactRequestProcessingResponse) ContactRequestProcessingResponse {
func (c *Contact) contactRequestRetracted(clock uint64, fromSyncing bool, r ContactRequestProcessingResponse) ContactRequestProcessingResponse {
if clock <= c.ContactRequestRemoteClock {
return r
}
Expand All @@ -298,7 +298,7 @@ func (c *Contact) contactRequestRetracted(clock uint64, syncing bool, r ContactR
// the side it was sent from. The only exception is when the contact
// request has been explicitly dismissed, in which case we don't
// change state
if c.ContactRequestLocalState != ContactRequestStateDismissed && !syncing {
if c.ContactRequestLocalState != ContactRequestStateDismissed && !fromSyncing {
c.ContactRequestLocalClock = clock
c.ContactRequestLocalState = ContactRequestStateNone
}
Expand All @@ -308,8 +308,8 @@ func (c *Contact) contactRequestRetracted(clock uint64, syncing bool, r ContactR
return r
}

func (c *Contact) ContactRequestRetracted(clock uint64, syncing bool) ContactRequestProcessingResponse {
return c.contactRequestRetracted(clock, syncing, ContactRequestProcessingResponse{})
func (c *Contact) ContactRequestRetracted(clock uint64, fromSyncing bool) ContactRequestProcessingResponse {
return c.contactRequestRetracted(clock, fromSyncing, ContactRequestProcessingResponse{})
}

func (c *Contact) contactRequestReceived(clock uint64, r ContactRequestProcessingResponse) ContactRequestProcessingResponse {
Expand Down
8 changes: 8 additions & 0 deletions protocol/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3554,8 +3554,16 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
}

senderID := contactIDFromPublicKey(publicKey)
ownID := contactIDFromPublicKey(m.IdentityPublicKey())
m.logger.Info("processing message", zap.Any("type", msg.Type), zap.String("senderID", senderID))

if senderID == ownID {
// Skip own messages of certain types
if msg.Type == protobuf.ApplicationMetadataMessage_CONTACT_CODE_ADVERTISEMENT {
continue
}
}

contact, contactFound := messageState.AllContacts.Load(senderID)

if _, ok := m.requestedContacts[senderID]; !ok {
Expand Down
2 changes: 1 addition & 1 deletion protocol/messenger_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ func (s *MessengerBackupSuite) TestBackupBlockedContacts() {
actualContacts := bob2.AddedContacts()
s.Require().Equal(actualContacts[0].ID, contactID1)

_, err = bob1.BlockContact(contactID1)
_, err = bob1.BlockContact(contactID1, false)
s.Require().NoError(err)

// Backup
Expand Down
Loading

0 comments on commit bbb8e99

Please sign in to comment.