Return request to join acceptance notifications (#4909)

This commit is contained in:
Ibrahem Khalil 2024-04-09 21:32:03 +02:00 committed by GitHub
parent e2a4a22896
commit 18cc3a16d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 2 deletions

View File

@ -1 +1 @@
0.179.1
0.179.2

View File

@ -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() {

View File

@ -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
}

View File

@ -5,6 +5,7 @@ const (
CategoryMessage PushCategory = "newMessage"
CategoryGroupInvite PushCategory = "groupInvite"
CategoryCommunityRequestToJoin = "communityRequestToJoin"
CategoryCommunityJoined = "communityJoined"
TypeTransaction NotificationType = "transaction"
TypeMessage NotificationType = "message"