From 44ded4dd642e6020738815f279dfa863e27d8f57 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Fri, 5 May 2023 18:26:19 +0300 Subject: [PATCH] fix(Messenger): Count SystemMessagePinnedMessage as unviewed (#3449) --- protocol/messenger_handler.go | 1 + protocol/messenger_pin_message_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/protocol/messenger_handler.go b/protocol/messenger_handler.go index 4f683be71..a39958b92 100644 --- a/protocol/messenger_handler.go +++ b/protocol/messenger_handler.go @@ -751,6 +751,7 @@ func (m *Messenger) handlePinMessage(pinner *Contact, whisperTimestamp uint64, r From: pinner.ID, } response.AddMessage(message) + chat.UnviewedMessagesCount++ } if chat.LastClockValue < message.Clock { diff --git a/protocol/messenger_pin_message_test.go b/protocol/messenger_pin_message_test.go index 7fadd1a5d..a4e0806a4 100644 --- a/protocol/messenger_pin_message_test.go +++ b/protocol/messenger_pin_message_test.go @@ -114,6 +114,7 @@ func (s *MessengerPinMessageSuite) TestPinMessageOutOfOrder() { ) s.Require().NoError(err) s.Require().Len(response.Chats(), 1) + s.Require().Equal(response.Chats()[0].UnviewedMessagesCount, uint(1)) // Unpin with higher clock @@ -136,6 +137,8 @@ func (s *MessengerPinMessageSuite) TestPinMessageOutOfOrder() { s.Require().Len(handlePinMessageResponse.PinMessages(), 1) 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 @@ -157,6 +160,8 @@ func (s *MessengerPinMessageSuite) TestPinMessageOutOfOrder() { s.Require().Len(handlePinMessageResponse.PinMessages(), 1) 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