diff --git a/VERSION b/VERSION index 3001a2a14..27f197fe7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.179.1 +0.179.2 diff --git a/protocol/communities_messenger_test.go b/protocol/communities_messenger_test.go index 3e30cb009..c08748e05 100644 --- a/protocol/communities_messenger_test.go +++ b/protocol/communities_messenger_test.go @@ -34,6 +34,7 @@ import ( "github.com/status-im/status-go/protocol/transport" "github.com/status-im/status-go/protocol/tt" v1protocol "github.com/status-im/status-go/protocol/v1" + localnotifications "github.com/status-im/status-go/services/local-notifications" "github.com/status-im/status-go/waku" ) @@ -411,6 +412,12 @@ func (s *MessengerCommunitiesSuite) TestJoinCommunity() { s.Require().True(response.Communities()[0].JoinedAt() > 0) s.Require().Len(response.Chats(), 2) s.Require().Len(response.Communities()[0].Categories(), 1) + s.Require().Len(response.notifications, 1) + for _, notification := range response.notifications { + s.Require().Equal(notification.Title, community.Name()) + s.Require().EqualValues(notification.BodyType, localnotifications.CategoryCommunityJoined) + s.Require().EqualValues(notification.Category, localnotifications.CategoryCommunityJoined) + } var categoryID string for k := range response.Communities()[0].Categories() { diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index 38e9e299a..abeab0df6 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -778,8 +778,9 @@ func (m *Messenger) unsubscribeFromShard(shard *shard.Shard) error { func (m *Messenger) joinCommunity(ctx context.Context, communityID types.HexBytes, forceJoin bool) (*MessengerResponse, error) { logger := m.logger.Named("joinCommunity") - response := &MessengerResponse{} + community, _ := m.communitiesManager.GetByID(communityID) + isCommunityMember := community.Joined() community, err := m.communitiesManager.JoinCommunity(communityID, forceJoin) if err != nil { @@ -824,6 +825,19 @@ func (m *Messenger) joinCommunity(ctx context.Context, communityID types.HexByte if err = m.PublishIdentityImage(); err != nil { return nil, err } + // Was applicant not a member and successfully joined? + if !isCommunityMember && community.Joined() { + joinedNotification := &localnotifications.Notification{ + ID: gethcommon.Hash(types.BytesToHash([]byte(`you-joined-` + communityID.String()))), + Title: community.Name(), + Message: community.Name(), + BodyType: localnotifications.CategoryCommunityJoined, + Category: localnotifications.CategoryCommunityJoined, + Deeplink: "status-app://cr/" + community.IDString(), + Image: "", + } + response.AddNotification(joinedNotification) + } return response, nil } diff --git a/services/local-notifications/types.go b/services/local-notifications/types.go index 587685bf1..efc2af1a1 100644 --- a/services/local-notifications/types.go +++ b/services/local-notifications/types.go @@ -5,6 +5,7 @@ const ( CategoryMessage PushCategory = "newMessage" CategoryGroupInvite PushCategory = "groupInvite" CategoryCommunityRequestToJoin = "communityRequestToJoin" + CategoryCommunityJoined = "communityJoined" TypeTransaction NotificationType = "transaction" TypeMessage NotificationType = "message"