Add config setting for API team deletion (#8800)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
e591fcf3d8
Коммит
c6cbce6100
@@ -197,7 +197,7 @@ func deleteTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var err *model.AppError
|
||||
if c.Params.Permanent {
|
||||
if c.Params.Permanent && *c.App.Config().ServiceSettings.EnableAPITeamDeletion {
|
||||
err = c.App.PermanentDeleteTeamId(c.Params.TeamId)
|
||||
} else {
|
||||
err = c.App.SoftDeleteTeam(c.Params.TeamId)
|
||||
|
||||
@@ -540,22 +540,25 @@ func TestPermanentDeleteTeam(t *testing.T) {
|
||||
team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_OPEN}
|
||||
team, _ = Client.CreateTeam(team)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableAPITeamDeletion = false })
|
||||
|
||||
// Does not error when deletion is disabled, just soft deletes
|
||||
ok, resp := Client.PermanentDeleteTeam(team.Id)
|
||||
CheckNoError(t, resp)
|
||||
assert.True(t, ok)
|
||||
|
||||
if !ok {
|
||||
t.Fatal("should have returned true")
|
||||
}
|
||||
|
||||
// The team is deleted in the background, its only soft deleted at this
|
||||
// time
|
||||
rteam, err := th.App.GetTeam(team.Id)
|
||||
if err != nil {
|
||||
t.Fatal("should have returned archived team")
|
||||
}
|
||||
if rteam.DeleteAt == 0 {
|
||||
t.Fatal("should have not set to zero")
|
||||
}
|
||||
assert.Nil(t, err)
|
||||
assert.True(t, rteam.DeleteAt > 0)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableAPITeamDeletion = true })
|
||||
|
||||
ok, resp = Client.PermanentDeleteTeam(team.Id)
|
||||
CheckNoError(t, resp)
|
||||
assert.True(t, ok)
|
||||
|
||||
_, err = th.App.GetTeam(team.Id)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
ok, resp = Client.PermanentDeleteTeam("junk")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
@@ -62,7 +62,8 @@
|
||||
"ExperimentalGroupUnreadChannels": "disabled",
|
||||
"ImageProxyType": "",
|
||||
"ImageProxyOptions": "",
|
||||
"ImageProxyURL": ""
|
||||
"ImageProxyURL": "",
|
||||
"EnableAPITeamDeletion": false
|
||||
},
|
||||
"TeamSettings": {
|
||||
"SiteName": "Mattermost",
|
||||
|
||||
@@ -224,6 +224,7 @@ type ServiceSettings struct {
|
||||
ImageProxyType *string
|
||||
ImageProxyURL *string
|
||||
ImageProxyOptions *string
|
||||
EnableAPITeamDeletion *bool
|
||||
}
|
||||
|
||||
func (s *ServiceSettings) SetDefaults() {
|
||||
@@ -452,6 +453,10 @@ func (s *ServiceSettings) SetDefaults() {
|
||||
if s.ImageProxyOptions == nil {
|
||||
s.ImageProxyOptions = NewString("")
|
||||
}
|
||||
|
||||
if s.EnableAPITeamDeletion == nil {
|
||||
s.EnableAPITeamDeletion = NewBool(false)
|
||||
}
|
||||
}
|
||||
|
||||
type ClusterSettings struct {
|
||||
|
||||
@@ -173,7 +173,7 @@ func ParamsFromRequest(r *http.Request) *Params {
|
||||
params.Page = val
|
||||
}
|
||||
|
||||
if val, err := strconv.ParseBool(query.Get("permanent")); err != nil {
|
||||
if val, err := strconv.ParseBool(query.Get("permanent")); err == nil {
|
||||
params.Permanent = val
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user