diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-04-04 02:35:29 +0900 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-04-03 10:35:29 -0700 |
commit | 997eacd4b635a2a7a86eadeeb2b229f153c52626 (patch) | |
tree | f9e517fba61ab4aa3c30e9ac1d7ea26310ad1589 /api4/team.go | |
parent | 43e795448f62fa86f3dad7940fc2297c44a6ea9c (diff) | |
download | chat-997eacd4b635a2a7a86eadeeb2b229f153c52626.tar.gz chat-997eacd4b635a2a7a86eadeeb2b229f153c52626.tar.bz2 chat-997eacd4b635a2a7a86eadeeb2b229f153c52626.zip |
APIv4 DELETE /teams/{team_id} (#5937)
Diffstat (limited to 'api4/team.go')
-rw-r--r-- | api4/team.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/api4/team.go b/api4/team.go index d71ccbf2e..6ea989a9b 100644 --- a/api4/team.go +++ b/api4/team.go @@ -26,6 +26,7 @@ func InitTeam() { BaseRoutes.Team.Handle("", ApiSessionRequired(getTeam)).Methods("GET") BaseRoutes.Team.Handle("", ApiSessionRequired(updateTeam)).Methods("PUT") + BaseRoutes.Team.Handle("", ApiSessionRequired(softDeleteTeam)).Methods("DELETE") BaseRoutes.Team.Handle("/patch", ApiSessionRequired(patchTeam)).Methods("PUT") BaseRoutes.Team.Handle("/stats", ApiSessionRequired(getTeamStats)).Methods("GET") BaseRoutes.TeamMembers.Handle("", ApiSessionRequired(getTeamMembers)).Methods("GET") @@ -165,6 +166,26 @@ func patchTeam(c *Context, w http.ResponseWriter, r *http.Request) { w.Write([]byte(patchedTeam.ToJson())) } +func softDeleteTeam(c *Context, w http.ResponseWriter, r *http.Request) { + c.RequireTeamId() + if c.Err != nil { + return + } + + if !app.SessionHasPermissionToTeam(c.Session, c.Params.TeamId, model.PERMISSION_MANAGE_TEAM) { + c.SetPermissionError(model.PERMISSION_MANAGE_TEAM) + return + } + + err := app.SoftDeleteTeam(c.Params.TeamId) + if err != nil { + c.Err = err + return + } + + ReturnStatusOK(w) +} + func getTeamsForUser(c *Context, w http.ResponseWriter, r *http.Request) { c.RequireUserId() if c.Err != nil { |