From 141a3e26333394357fce061fe2b404f30409dde3 Mon Sep 17 00:00:00 2001 From: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com> Date: Wed, 26 Apr 2023 22:00:54 +0800 Subject: [PATCH] [Fix] Added Community Kicked notification to response (#3427) * [Fix] Added Community Kicked notification to response * Added unit test and updated response merge method * Update VERSION --- VERSION | 2 +- protocol/communities_messenger_test.go | 6 ++++++ protocol/messenger.go | 8 +++++++- protocol/messenger_response.go | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 5edc0a741..b4db76bfc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.148.0 +0.148.1 diff --git a/protocol/communities_messenger_test.go b/protocol/communities_messenger_test.go index 219c0366b..f87525203 100644 --- a/protocol/communities_messenger_test.go +++ b/protocol/communities_messenger_test.go @@ -1909,6 +1909,12 @@ func (s *MessengerCommunitiesSuite) TestRequestAccessAgain() { if len(response.Communities()) == 0 { return errors.New("community not received") } + if len(response.ActivityCenterNotifications()) == 0 { + return errors.New("activity center notification not received") + } + if response.ActivityCenterState().HasSeen { + return errors.New("activity center seen state is incorrect") + } return nil }) diff --git a/protocol/messenger.go b/protocol/messenger.go index 80a2c5f82..4f7d80422 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -4347,11 +4347,17 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte Type: ActivityCenterNotificationTypeCommunityKicked, Timestamp: m.getTimesource().GetCurrentTime(), CommunityID: changes.Community.IDString(), + Read: false, } err = m.addActivityCenterNotification(response, notification) if err != nil { - m.logger.Error("failed to save notification", zap.Error(err)) + logger.Error("failed to save notification", zap.Error(err)) + continue + } + + if err := messageState.Response.Merge(response); err != nil { + logger.Error("cannot merge notification response", zap.Error(err)) continue } } diff --git a/protocol/messenger_response.go b/protocol/messenger_response.go index ea0317333..ccc5f811a 100644 --- a/protocol/messenger_response.go +++ b/protocol/messenger_response.go @@ -306,6 +306,7 @@ func (r *MessengerResponse) Merge(response *MessengerResponse) error { r.AddVerificationRequests(response.VerificationRequests()) r.AddTrustStatuses(response.trustStatus) r.AddActivityCenterNotifications(response.ActivityCenterNotifications()) + r.SetActivityCenterState(response.ActivityCenterState()) r.AddEmojiReactions(response.EmojiReactions()) r.AddInstallations(response.Installations) r.AddSavedAddresses(response.SavedAddresses())