Remove contact from the contact list of contacts the blocked contact

* Remove contact from the user's list of contacts when the contact is blocked by the user

* added test for removed blocked contact
This commit is contained in:
John Ngei 2023-04-20 13:52:08 +03:00 committed by GitHub
parent 272173c939
commit 9dea0aaee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 1 deletions

View File

@ -1 +1 @@
0.146.2 0.146.3

View File

@ -155,6 +155,7 @@ func (c Contact) PublicKey() (*ecdsa.PublicKey, error) {
func (c *Contact) Block(clock uint64) { func (c *Contact) Block(clock uint64) {
c.Blocked = true c.Blocked = true
c.DismissContactRequest(clock) c.DismissContactRequest(clock)
c.Removed = true
} }
func (c *Contact) BlockDesktop() { func (c *Contact) BlockDesktop() {

View File

@ -669,6 +669,11 @@ func (m *Messenger) blockContact(contactID string, isDesktopFunc bool) ([]*Chat,
return nil, err return nil, err
} }
err = m.sendRetractContactRequest(contact)
if err != nil {
return nil, err
}
m.allContacts.Store(contact.ID, contact) m.allContacts.Store(contact.ID, contact)
for _, chat := range chats { for _, chat := range chats {
m.allChats.Store(chat.ID, chat) m.allChats.Store(chat.ID, chat)

View File

@ -1378,6 +1378,9 @@ func (s *MessengerSuite) TestBlockContact() {
response, err := s.m.BlockContact(contact.ID) response, err := s.m.BlockContact(contact.ID)
s.Require().NoError(err) s.Require().NoError(err)
blockedContacts := s.m.BlockedContacts()
s.Require().True(blockedContacts[0].Removed)
chats := response.Chats() chats := response.Chats()
var actualChat2, actualChat3 *Chat var actualChat2, actualChat3 *Chat