Remove remote contact when removing localy (#2735)

This commit is contained in:
Audrius Molis 2022-07-07 11:49:52 +03:00 committed by GitHub
parent 8e9c5d31d1
commit d17b076bc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 10 deletions

View File

@ -550,6 +550,11 @@ func (m *Messenger) blockContact(contactID string, isDesktopFunc bool) ([]*Chat,
} else {
contact.Block()
}
_, retractErr := m.retractContactRequest(contact)
if retractErr != nil {
return nil, retractErr
}
contact.LastUpdatedLocally = m.getTimesource().GetCurrentTime()
chats, err := m.persistence.BlockContact(contact, isDesktopFunc)
@ -769,19 +774,11 @@ func (m *Messenger) addENSNameToContact(contact *Contact) error {
return nil
}
func (m *Messenger) RetractContactRequest(request *requests.RetractContactRequest) (*MessengerResponse, error) {
err := request.Validate()
if err != nil {
return nil, err
}
contact, ok := m.allContacts.Load(request.ContactID.String())
if !ok {
return nil, errors.New("contact not found")
}
func (m *Messenger) retractContactRequest(contact *Contact) (*MessengerResponse, error) {
contact.HasAddedUs = false
m.allContacts.Store(contact.ID, contact)
response := &MessengerResponse{}
err = m.removeContact(context.Background(), response, contact.ID)
err := m.removeContact(context.Background(), response, contact.ID)
if err != nil {
return nil, err
}
@ -821,6 +818,19 @@ func (m *Messenger) RetractContactRequest(request *requests.RetractContactReques
return response, err
}
func (m *Messenger) RetractContactRequest(request *requests.RetractContactRequest) (*MessengerResponse, error) {
err := request.Validate()
if err != nil {
return nil, err
}
contact, ok := m.allContacts.Load(request.ContactID.String())
if !ok {
return nil, errors.New("contact not found")
}
return m.retractContactRequest(contact)
}
func (m *Messenger) AcceptLatestContactRequestForContact(ctx context.Context, request *requests.AcceptLatestContactRequestForContact) (*MessengerResponse, error) {
if err := request.Validate(); err != nil {
return nil, err