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