summaryrefslogtreecommitdiffstats
path: root/model/client.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-07-06 13:40:59 -0800
committerGitHub <noreply@github.com>2016-07-06 13:40:59 -0800
commitd5f243dad694d6746ec2b6560a81212a78d8c975 (patch)
tree7f1de697c906ff909f26b739eebaa77f18edf790 /model/client.go
parent3eee51f74e893f3182519ad0edb72dd5d8b107fd (diff)
downloadchat-d5f243dad694d6746ec2b6560a81212a78d8c975.tar.gz
chat-d5f243dad694d6746ec2b6560a81212a78d8c975.tar.bz2
chat-d5f243dad694d6746ec2b6560a81212a78d8c975.zip
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
Diffstat (limited to 'model/client.go')
-rw-r--r--model/client.go32
1 files changed, 30 insertions, 2 deletions
diff --git a/model/client.go b/model/client.go
index 1882fd0ab..2f1e846c2 100644
--- a/model/client.go
+++ b/model/client.go
@@ -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