feat: Dispatch profile showcase message on mutual/verified contacts change (#4678)

This commit is contained in:
Mikhail Rogachev 2024-02-09 12:36:54 +03:00 committed by GitHub
parent 005e7e6ee4
commit 2350461818
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 0 deletions

View File

@ -451,6 +451,12 @@ func (m *Messenger) VerifiedTrusted(ctx context.Context, request *requests.Verif
return nil, err return nil, err
} }
// Dispatch profile message to save a contact to the encrypted profile part
err = m.DispatchProfileShowcase()
if err != nil {
return nil, err
}
response := &MessengerResponse{} response := &MessengerResponse{}
notification.ContactVerificationStatus = verification.RequestStatusTRUSTED notification.ContactVerificationStatus = verification.RequestStatusTRUSTED
@ -558,6 +564,12 @@ func (m *Messenger) VerifiedUntrustworthy(ctx context.Context, request *requests
return nil, err return nil, err
} }
// Dispatch profile message to remove a contact from the encrypted profile part
err = m.DispatchProfileShowcase()
if err != nil {
return nil, err
}
response := &MessengerResponse{} response := &MessengerResponse{}
notification.ContactVerificationStatus = verification.RequestStatusUNTRUSTWORTHY notification.ContactVerificationStatus = verification.RequestStatusUNTRUSTWORTHY
@ -713,6 +725,12 @@ func (m *Messenger) RemoveTrustStatus(ctx context.Context, contactID string) err
return err return err
} }
// Dispatch profile message to remove a contact from the encrypted profile part
err = m.DispatchProfileShowcase()
if err != nil {
return err
}
return m.SyncTrustedUser(ctx, contactID, verification.TrustStatusUNKNOWN, m.dispatchMessage) return m.SyncTrustedUser(ctx, contactID, verification.TrustStatusUNKNOWN, m.dispatchMessage)
} }

View File

@ -303,6 +303,12 @@ func (m *Messenger) updateAcceptedContactRequest(response *MessengerResponse, co
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Dispatch profile message to add a contact to the encrypted profile part
err = m.DispatchProfileShowcase()
if err != nil {
return nil, err
}
} }
if response == nil { if response == nil {
@ -682,6 +688,12 @@ func (m *Messenger) removeContact(ctx context.Context, response *MessengerRespon
return err return err
} }
// Dispatch profile message to remove a contact from the encrypted profile part
err = m.DispatchProfileShowcase()
if err != nil {
return err
}
// Profile chats are deprecated. // Profile chats are deprecated.
// Code below can be removed after some reasonable time. // Code below can be removed after some reasonable time.

View File

@ -1038,6 +1038,12 @@ func (m *Messenger) handleAcceptContactRequestMessage(state *ReceivedMessageStat
return err return err
} }
chat.UnviewedMessagesCount++ chat.UnviewedMessagesCount++
// Dispatch profile message to add a contact to the encrypted profile part
err = m.DispatchProfileShowcase()
if err != nil {
return err
}
} }
state.Response.AddChat(chat) state.Response.AddChat(chat)
@ -1110,6 +1116,12 @@ func (m *Messenger) handleRetractContactRequest(state *ReceivedMessageState, con
return err return err
} }
// Dispatch profile message to remove a contact from the encrypted profile part
err = m.DispatchProfileShowcase()
if err != nil {
return err
}
err = m.prepareMessage(updateMessage, m.httpServer) err = m.prepareMessage(updateMessage, m.httpServer)
if err != nil { if err != nil {
return err return err