MM-20977 - Inviting multiple users with valid/allowed and inva… (#13779)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
682a1d5d15
Коммит
4b39d8487b
@@ -1985,6 +1985,31 @@ func (c *Client4) InviteGuestsToTeam(teamId string, userEmails []string, channel
|
||||
return CheckStatusOK(r), BuildResponse(r)
|
||||
}
|
||||
|
||||
// InviteUsersToTeam invite users by email to the team.
|
||||
func (c *Client4) InviteUsersToTeamGracefully(teamId string, userEmails []string) ([]*EmailInviteWithError, *Response) {
|
||||
r, err := c.DoApiPost(c.GetTeamRoute(teamId)+"/invite/email?graceful=true", ArrayToJson(userEmails))
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return EmailInviteWithErrorFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
|
||||
// InviteGuestsToTeam invite guest by email to some channels in a team.
|
||||
func (c *Client4) InviteGuestsToTeamGracefully(teamId string, userEmails []string, channels []string, message string) ([]*EmailInviteWithError, *Response) {
|
||||
guestsInvite := GuestsInvite{
|
||||
Emails: userEmails,
|
||||
Channels: channels,
|
||||
Message: message,
|
||||
}
|
||||
r, err := c.DoApiPost(c.GetTeamRoute(teamId)+"/invite-guests/email?graceful=true", guestsInvite.ToJson())
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return EmailInviteWithErrorFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
|
||||
// InvalidateEmailInvites will invalidate active email invitations that have not been accepted by the user.
|
||||
func (c *Client4) InvalidateEmailInvites() (bool, *Response) {
|
||||
r, err := c.DoApiDelete(c.GetTeamsRoute() + "/invites/email")
|
||||
|
||||
@@ -38,6 +38,11 @@ type TeamMemberWithError struct {
|
||||
Error *AppError `json:"error"`
|
||||
}
|
||||
|
||||
type EmailInviteWithError struct {
|
||||
Email string `json:"email"`
|
||||
Error *AppError `json:"error"`
|
||||
}
|
||||
|
||||
func (o *TeamMember) ToJson() string {
|
||||
b, _ := json.Marshal(o)
|
||||
return string(b)
|
||||
@@ -60,6 +65,30 @@ func TeamUnreadFromJson(data io.Reader) *TeamUnread {
|
||||
return o
|
||||
}
|
||||
|
||||
func EmailInviteWithErrorFromJson(data io.Reader) []*EmailInviteWithError {
|
||||
var o []*EmailInviteWithError
|
||||
json.NewDecoder(data).Decode(&o)
|
||||
return o
|
||||
}
|
||||
|
||||
func EmailInviteWithErrorToEmails(o []*EmailInviteWithError) []string {
|
||||
var ret []string
|
||||
for _, o := range o {
|
||||
if o.Error == nil {
|
||||
ret = append(ret, o.Email)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func EmailInviteWithErrorToJson(o []*EmailInviteWithError) string {
|
||||
if b, err := json.Marshal(o); err != nil {
|
||||
return "[]"
|
||||
} else {
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
func TeamMembersWithErrorToTeamMembers(o []*TeamMemberWithError) []*TeamMember {
|
||||
var ret []*TeamMember
|
||||
for _, o := range o {
|
||||
|
||||
Ссылка в новой задаче
Block a user