fix(Messenger): Count SystemMessagePinnedMessage as unviewed (#3449)

This commit is contained in:
Igor Sirotin 2023-05-05 18:26:19 +03:00 committed by GitHub
parent 46bac20260
commit 44ded4dd64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -751,6 +751,7 @@ func (m *Messenger) handlePinMessage(pinner *Contact, whisperTimestamp uint64, r
From: pinner.ID, From: pinner.ID,
} }
response.AddMessage(message) response.AddMessage(message)
chat.UnviewedMessagesCount++
} }
if chat.LastClockValue < message.Clock { if chat.LastClockValue < message.Clock {

View File

@ -114,6 +114,7 @@ func (s *MessengerPinMessageSuite) TestPinMessageOutOfOrder() {
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Equal(response.Chats()[0].UnviewedMessagesCount, uint(1))
// Unpin with higher clock // Unpin with higher clock
@ -136,6 +137,8 @@ func (s *MessengerPinMessageSuite) TestPinMessageOutOfOrder() {
s.Require().Len(handlePinMessageResponse.PinMessages(), 1) s.Require().Len(handlePinMessageResponse.PinMessages(), 1)
s.Require().False(handlePinMessageResponse.PinMessages()[0].Pinned) s.Require().False(handlePinMessageResponse.PinMessages()[0].Pinned)
s.Require().Len(handlePinMessageResponse.Chats(), 1)
s.Require().Equal(handlePinMessageResponse.Chats()[0].UnviewedMessagesCount, uint(0))
// Pin with lower clock in response // Pin with lower clock in response
@ -157,6 +160,8 @@ func (s *MessengerPinMessageSuite) TestPinMessageOutOfOrder() {
s.Require().Len(handlePinMessageResponse.PinMessages(), 1) s.Require().Len(handlePinMessageResponse.PinMessages(), 1)
s.Require().False(handlePinMessageResponse.PinMessages()[0].Pinned) s.Require().False(handlePinMessageResponse.PinMessages()[0].Pinned)
s.Require().Len(handlePinMessageResponse.Chats(), 1)
s.Require().Equal(handlePinMessageResponse.Chats()[0].UnviewedMessagesCount, uint(0))
// Pin with lower clock not in response // Pin with lower clock not in response