Make sure message has correctly set contact notification state
In case we received a message with propagated state, the message state wasn't correctly set in the database.
This commit is contained in:
parent
08403df4c0
commit
dab0e5d6d3
|
@ -114,6 +114,16 @@ func (s *MessengerContactRequestSuite) TestReceiveAndAcceptContactRequest() { //
|
|||
s.Require().Equal(resp.ActivityCenterNotifications()[0].Accepted, false)
|
||||
s.Require().Equal(resp.ActivityCenterNotifications()[0].Dismissed, false)
|
||||
|
||||
s.Require().Equal(common.ContactRequestStatePending, resp.Messages()[0].ContactRequestState)
|
||||
|
||||
notifications, err := theirMessenger.ActivityCenterNotifications("", 10)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Require().Len(notifications.Notifications, 1)
|
||||
|
||||
s.Require().NotNil(common.ContactRequestStatePending, notifications.Notifications[0].Message)
|
||||
s.Require().Equal(common.ContactRequestStatePending, notifications.Notifications[0].Message.ContactRequestState)
|
||||
|
||||
// Check the contact state is correctly set
|
||||
s.Require().Len(resp.Contacts, 1)
|
||||
s.Require().Equal(ContactRequestStateReceived, resp.Contacts[0].ContactRequestRemoteState)
|
||||
|
|
|
@ -1750,6 +1750,11 @@ func (m *Messenger) HandleChatMessage(state *ReceivedMessageState) error {
|
|||
}
|
||||
}
|
||||
if result.newContactRequestReceived {
|
||||
|
||||
if contact.hasAddedUs() && !contact.mutual() {
|
||||
receivedMessage.ContactRequestState = common.ContactRequestStatePending
|
||||
}
|
||||
|
||||
err = m.createContactRequestNotification(contact, state, receivedMessage, true)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue