diff --git a/protocol/communities_messenger_test.go b/protocol/communities_messenger_test.go index 78d367bcb..bc6abce1f 100644 --- a/protocol/communities_messenger_test.go +++ b/protocol/communities_messenger_test.go @@ -1188,6 +1188,8 @@ func (s *MessengerCommunitiesSuite) TestShareCommunity() { Description: "status community description", } + inviteMessage := "invite to community testing message" + // Create an community chat response, err := s.bob.CreateCommunity(description, true) s.Require().NoError(err) @@ -1198,8 +1200,9 @@ func (s *MessengerCommunitiesSuite) TestShareCommunity() { response, err = s.bob.ShareCommunity( &requests.ShareCommunity{ - CommunityID: community.ID(), - Users: []types.HexBytes{common.PubkeyToHexBytes(&s.alice.identity.PublicKey)}, + CommunityID: community.ID(), + Users: []types.HexBytes{common.PubkeyToHexBytes(&s.alice.identity.PublicKey)}, + InviteMessage: inviteMessage, }, ) s.Require().NoError(err) @@ -1226,6 +1229,10 @@ func (s *MessengerCommunitiesSuite) TestShareCommunity() { s.Require().NoError(err) s.Require().Len(response.Messages(), 1) + + message := response.Messages()[0] + s.Require().Equal(community.IDString(), message.CommunityID) + s.Require().Equal(inviteMessage, message.Text) } func (s *MessengerCommunitiesSuite) TestBanUser() { diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index 1a6e8d009..79443ce09 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -987,6 +987,9 @@ func (m *Messenger) ShareCommunity(request *requests.ShareCommunity) (*Messenger message.ChatId = pk.String() message.CommunityID = request.CommunityID.String() message.Text = fmt.Sprintf("Community %s has been shared with you", community.Name()) + if request.InviteMessage != "" { + message.Text = request.InviteMessage + } messages = append(messages, message) r, err := m.CreateOneToOneChat(&requests.CreateOneToOneChat{ID: pk}) if err != nil { diff --git a/protocol/requests/share_community.go b/protocol/requests/share_community.go index 748cc22e5..8402fa281 100644 --- a/protocol/requests/share_community.go +++ b/protocol/requests/share_community.go @@ -10,8 +10,9 @@ var ErrShareCommunityInvalidID = errors.New("share-community: invalid id") var ErrShareCommunityEmptyUsers = errors.New("share-community: empty users") type ShareCommunity struct { - CommunityID types.HexBytes `json:"communityId"` - Users []types.HexBytes `json:"users"` + CommunityID types.HexBytes `json:"communityId"` + Users []types.HexBytes `json:"users"` + InviteMessage string `json:"inviteMessage,omitempty"` } func (j *ShareCommunity) Validate() error {