diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index 74b842907..088b92a60 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -1049,6 +1049,26 @@ func (m *Messenger) joinCommunity(ctx context.Context, communityID types.HexByte Image: "", } response.AddNotification(joinedNotification) + + // Activity Center notification + requestID := communities.CalculateRequestID(common.PubkeyToHex(&m.identity.PublicKey), communityID) + notification, err := m.persistence.GetActivityCenterNotificationByID(requestID) + if err != nil { + return nil, err + } + + if notification != nil && notification.MembershipStatus != ActivityCenterMembershipStatusAccepted { + notification.MembershipStatus = ActivityCenterMembershipStatusAccepted + notification.Read = false + notification.Deleted = false + + notification.UpdatedAt = m.GetCurrentTimeInMillis() + err = m.addActivityCenterNotification(response, notification, nil) + if err != nil { + m.logger.Error("failed to update request to join accepted notification", zap.Error(err)) + return nil, err + } + } } return response, nil diff --git a/protocol/messenger_handler.go b/protocol/messenger_handler.go index 922fa29f9..2c26d74ee 100644 --- a/protocol/messenger_handler.go +++ b/protocol/messenger_handler.go @@ -1730,29 +1730,6 @@ func (m *Messenger) HandleCommunityRequestToJoinResponse(state *ReceivedMessageS } } - // Activity Center notification - requestID := communities.CalculateRequestID(common.PubkeyToHex(&m.identity.PublicKey), requestToJoinResponseProto.CommunityId) - notification, err := m.persistence.GetActivityCenterNotificationByID(requestID) - if err != nil { - return err - } - - if notification != nil { - if requestToJoinResponseProto.Accepted { - notification.MembershipStatus = ActivityCenterMembershipStatusAccepted - notification.Read = false - notification.Deleted = false - } else { - notification.MembershipStatus = ActivityCenterMembershipStatusDeclined - } - notification.UpdatedAt = m.GetCurrentTimeInMillis() - err = m.addActivityCenterNotification(state.Response, notification, nil) - if err != nil { - m.logger.Error("failed to update notification", zap.Error(err)) - return err - } - } - return nil }