diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-03-24 21:17:46 +0900 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-03-24 08:17:46 -0400 |
commit | d0af931e6e57b78432d5527b6e7b0be36c538144 (patch) | |
tree | 7196ec5e627fe27b539f982df4374e2d2d381f14 /api4/team.go | |
parent | 4c1eb7ff5575be07b8410e76da4cdaa964c2ef91 (diff) | |
download | chat-d0af931e6e57b78432d5527b6e7b0be36c538144.tar.gz chat-d0af931e6e57b78432d5527b6e7b0be36c538144.tar.bz2 chat-d0af931e6e57b78432d5527b6e7b0be36c538144.zip |
APIv4 put /teams/{team_id}/patch (#5860)
Diffstat (limited to 'api4/team.go')
-rw-r--r-- | api4/team.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/api4/team.go b/api4/team.go index 26fff7ce1..a9be5c8ab 100644 --- a/api4/team.go +++ b/api4/team.go @@ -22,6 +22,7 @@ func InitTeam() { BaseRoutes.Team.Handle("", ApiSessionRequired(getTeam)).Methods("GET") BaseRoutes.Team.Handle("", ApiSessionRequired(updateTeam)).Methods("PUT") + BaseRoutes.Team.Handle("/patch", ApiSessionRequired(patchTeam)).Methods("PUT") BaseRoutes.Team.Handle("/stats", ApiSessionRequired(getTeamStats)).Methods("GET") BaseRoutes.TeamMembers.Handle("", ApiSessionRequired(getTeamMembers)).Methods("GET") BaseRoutes.TeamMembers.Handle("/ids", ApiSessionRequired(getTeamMembersByIds)).Methods("POST") @@ -127,6 +128,35 @@ func updateTeam(c *Context, w http.ResponseWriter, r *http.Request) { w.Write([]byte(updatedTeam.ToJson())) } +func patchTeam(c *Context, w http.ResponseWriter, r *http.Request) { + c.RequireTeamId() + if c.Err != nil { + return + } + + team := model.TeamPatchFromJson(r.Body) + + if team == nil { + c.SetInvalidParam("team") + return + } + + if !app.SessionHasPermissionToTeam(c.Session, c.Params.TeamId, model.PERMISSION_MANAGE_TEAM) { + c.SetPermissionError(model.PERMISSION_MANAGE_TEAM) + return + } + + patchedTeam, err := app.PatchTeam(c.Params.TeamId, team) + + if err != nil { + c.Err = err + return + } + + c.LogAudit("") + w.Write([]byte(patchedTeam.ToJson())) +} + func getTeamsForUser(c *Context, w http.ResponseWriter, r *http.Request) { c.RequireUserId() if c.Err != nil { |