summaryrefslogtreecommitdiffstats
path: root/api4/team.go
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <ZJvandeWeg@users.noreply.github.com>2017-06-15 14:13:18 +0200
committerJoram Wilander <jwawilander@gmail.com>2017-06-15 08:13:18 -0400
commit0c04c5334fc89cf62a4bd3c1ce20469523a24026 (patch)
tree30b56cf82205ef5d739059ec1b3a24865e8d0fb3 /api4/team.go
parent98ac903fce24418538edbec77a218bcac9e20cd2 (diff)
downloadchat-0c04c5334fc89cf62a4bd3c1ce20469523a24026.tar.gz
chat-0c04c5334fc89cf62a4bd3c1ce20469523a24026.tar.bz2
chat-0c04c5334fc89cf62a4bd3c1ce20469523a24026.zip
Add APIv4 endpoint to permanently delete teams (#6604)
Tests are added, however, it only tests the property if its soft deleted. In the background it will be hard deleted, but that is untestable through a integration test.
Diffstat (limited to 'api4/team.go')
-rw-r--r--api4/team.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/api4/team.go b/api4/team.go
index b8ba47054..57a715937 100644
--- a/api4/team.go
+++ b/api4/team.go
@@ -30,7 +30,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("", ApiSessionRequired(deleteTeam)).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")
@@ -172,7 +172,7 @@ 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) {
+func deleteTeam(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireTeamId()
if c.Err != nil {
return
@@ -183,7 +183,13 @@ func softDeleteTeam(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- err := app.SoftDeleteTeam(c.Params.TeamId)
+ var err *model.AppError
+ if c.Params.Permanent {
+ err = app.PermanentDeleteTeamId(c.Params.TeamId)
+ } else {
+ err = app.SoftDeleteTeam(c.Params.TeamId)
+ }
+
if err != nil {
c.Err = err
return