summaryrefslogtreecommitdiffstats
path: root/model
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
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')
-rw-r--r--model/client.go32
-rw-r--r--model/message.go1
-rw-r--r--model/team_member.go7
3 files changed, 35 insertions, 5 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
diff --git a/model/message.go b/model/message.go
index a986af4de..12f3be663 100644
--- a/model/message.go
+++ b/model/message.go
@@ -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"
diff --git a/model/team_member.go b/model/team_member.go
index ae687c109..7d932dec4 100644
--- a/model/team_member.go
+++ b/model/team_member.go
@@ -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 {