feat: add optional inviteMessage to share-community request (#2776)
This commit is contained in:
parent
31671ea040
commit
cd91b19737
|
@ -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() {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue