PLT-2863 adding remove user from team (#3429)
* PLT-2863 adding remove user from team * PLT-2863 adding the client side UI * Fixing trailing space * Fixing reported issues * Adding documentatino * Switching to final javascript driver
Этот коммит содержится в:
@@ -345,10 +345,18 @@ func (c *Client) FindTeamByName(name string) (*Result, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) AddUserToTeam(userId string) (*Result, *AppError) {
|
||||
// Adds a user directly to the team without sending an invite.
|
||||
// The teamId and userId are required. You must be a valid member of the team and/or
|
||||
// have the correct role to add new users to the team. Returns a map of user_id=userId
|
||||
// if successful, otherwise returns an AppError.
|
||||
func (c *Client) AddUserToTeam(teamId string, userId string) (*Result, *AppError) {
|
||||
if len(teamId) == 0 {
|
||||
teamId = c.GetTeamId()
|
||||
}
|
||||
|
||||
data := make(map[string]string)
|
||||
data["user_id"] = userId
|
||||
if r, err := c.DoApiPost(c.GetTeamRoute()+"/add_user_to_team", MapToJson(data)); err != nil {
|
||||
if r, err := c.DoApiPost(fmt.Sprintf("/teams/%v", teamId)+"/add_user_to_team", MapToJson(data)); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
@@ -371,6 +379,26 @@ func (c *Client) AddUserToTeamFromInvite(hash, dataToHash, inviteId string) (*Re
|
||||
}
|
||||
}
|
||||
|
||||
// Removes a user directly from the team.
|
||||
// The teamId and userId are required. You must be a valid member of the team and/or
|
||||
// have the correct role to remove a user from the team. Returns a map of user_id=userId
|
||||
// if successful, otherwise returns an AppError.
|
||||
func (c *Client) RemoveUserFromTeam(teamId string, userId string) (*Result, *AppError) {
|
||||
if len(teamId) == 0 {
|
||||
teamId = c.GetTeamId()
|
||||
}
|
||||
|
||||
data := make(map[string]string)
|
||||
data["user_id"] = userId
|
||||
if r, err := c.DoApiPost(fmt.Sprintf("/teams/%v", teamId)+"/remove_user_from_team", MapToJson(data)); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) InviteMembers(invites *Invites) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetTeamRoute()+"/invite_members", invites.ToJson()); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -17,6 +17,7 @@ const (
|
||||
ACTION_CHANNEL_VIEWED = "channel_viewed"
|
||||
ACTION_DIRECT_ADDED = "direct_added"
|
||||
ACTION_NEW_USER = "new_user"
|
||||
ACTION_LEAVE_TEAM = "leave_team"
|
||||
ACTION_USER_ADDED = "user_added"
|
||||
ACTION_USER_REMOVED = "user_removed"
|
||||
ACTION_PREFERENCE_CHANGED = "preference_changed"
|
||||
|
||||
@@ -14,9 +14,10 @@ const (
|
||||
)
|
||||
|
||||
type TeamMember struct {
|
||||
TeamId string `json:"team_id"`
|
||||
UserId string `json:"user_id"`
|
||||
Roles string `json:"roles"`
|
||||
TeamId string `json:"team_id"`
|
||||
UserId string `json:"user_id"`
|
||||
Roles string `json:"roles"`
|
||||
DeleteAt int64 `json:"delete_at"`
|
||||
}
|
||||
|
||||
func (o *TeamMember) ToJson() string {
|
||||
|
||||
Ссылка в новой задаче
Block a user