Return request to join acceptance notifications (#4909)
This commit is contained in:
parent
e2a4a22896
commit
18cc3a16d5
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ const (
|
|||
CategoryMessage PushCategory = "newMessage"
|
||||
CategoryGroupInvite PushCategory = "groupInvite"
|
||||
CategoryCommunityRequestToJoin = "communityRequestToJoin"
|
||||
CategoryCommunityJoined = "communityJoined"
|
||||
|
||||
TypeTransaction NotificationType = "transaction"
|
||||
TypeMessage NotificationType = "message"
|
||||
|
|
Loading…
Reference in New Issue