Allow receiving old messages after rejoining a pubchat

This commit is contained in:
Roman Volosovskyi 2020-11-04 15:35:23 +02:00
parent 75e0809f50
commit fa136ebaa7
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
3 changed files with 32 additions and 3 deletions

View File

@ -1 +1 @@
0.63.2
0.63.3

View File

@ -355,7 +355,7 @@ func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error {
}
// If deleted-at is greater, ignore message
if chat.DeletedAtClockValue >= receivedMessage.Clock {
if chat.DeletedAtClockValue >= receivedMessage.Clock && !chat.Public() {
return nil
}

View File

@ -566,6 +566,35 @@ func (s *MessengerSuite) TestRetrieveTheirPublic() {
}
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)
s.Require().NoError(theirMessenger.Start())
theirChat := CreatePublicChat("status", s.m.transport)
@ -592,7 +621,7 @@ func (s *MessengerSuite) TestDeletedAtClockValue() {
time.Sleep(100 * time.Millisecond)
response, err := s.m.RetrieveAll()
s.Require().NoError(err)
s.Require().Len(response.Messages, 0)
s.Require().Len(response.Messages, 1)
s.Require().NoError(theirMessenger.Shutdown())
}