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
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
|
||||
// timeoutManager represents a discrete encapsulation of timeout functionality.
|
||||
// this struct expose 3 functions:
|
||||
// - SetTimeout
|
||||
// - StartTimeout
|
||||
// - StopTimeout
|
||||
// - SetTimeout
|
||||
// - StartTimeout
|
||||
// - StopTimeout
|
||||
type timeoutManager struct {
|
||||
// timeout number of milliseconds the timeout operation will run before executing the `terminate` func()
|
||||
// 0 represents an inactive timeout
|
||||
|
|
Loading…
Reference in New Issue