Allow receiving old messages after rejoining a pubchat
This commit is contained in:
parent
75e0809f50
commit
fa136ebaa7
|
@ -355,7 +355,7 @@ func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If deleted-at is greater, ignore message
|
// If deleted-at is greater, ignore message
|
||||||
if chat.DeletedAtClockValue >= receivedMessage.Clock {
|
if chat.DeletedAtClockValue >= receivedMessage.Clock && !chat.Public() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -566,6 +566,35 @@ func (s *MessengerSuite) TestRetrieveTheirPublic() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MessengerSuite) TestDeletedAtClockValue() {
|
func (s *MessengerSuite) TestDeletedAtClockValue() {
|
||||||
|
theirMessenger := s.newMessenger(s.shh)
|
||||||
|
s.Require().NoError(theirMessenger.Start())
|
||||||
|
theirChat := CreateOneToOneChat("XXX", &s.privateKey.PublicKey, s.m.transport)
|
||||||
|
err := theirMessenger.SaveChat(&theirChat)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
ourChat := CreateOneToOneChat("our-chat", &theirMessenger.identity.PublicKey, s.m.transport)
|
||||||
|
ourChat.UnviewedMessagesCount = 1
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
inputMessage := buildTestMessage(theirChat)
|
||||||
|
|
||||||
|
sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
|
||||||
|
s.NoError(err)
|
||||||
|
s.Require().Len(sendResponse.Messages, 1)
|
||||||
|
|
||||||
|
ourChat.DeletedAtClockValue = sendResponse.Messages[0].Clock
|
||||||
|
err = s.m.SaveChat(&ourChat)
|
||||||
|
s.NoError(err)
|
||||||
|
|
||||||
|
// Wait for the message to reach its destination
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
response, err := s.m.RetrieveAll()
|
||||||
|
s.Require().NoError(err)
|
||||||
|
s.Require().Len(response.Messages, 0)
|
||||||
|
s.Require().NoError(theirMessenger.Shutdown())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MessengerSuite) TestDeletedAtClockValuePubChat() {
|
||||||
theirMessenger := s.newMessenger(s.shh)
|
theirMessenger := s.newMessenger(s.shh)
|
||||||
s.Require().NoError(theirMessenger.Start())
|
s.Require().NoError(theirMessenger.Start())
|
||||||
theirChat := CreatePublicChat("status", s.m.transport)
|
theirChat := CreatePublicChat("status", s.m.transport)
|
||||||
|
@ -592,7 +621,7 @@ func (s *MessengerSuite) TestDeletedAtClockValue() {
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
response, err := s.m.RetrieveAll()
|
response, err := s.m.RetrieveAll()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(response.Messages, 0)
|
s.Require().Len(response.Messages, 1)
|
||||||
s.Require().NoError(theirMessenger.Shutdown())
|
s.Require().NoError(theirMessenger.Shutdown())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue