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
|
var err *model.AppError
|
||||||
if c.Params.Permanent {
|
if c.Params.Permanent && *c.App.Config().ServiceSettings.EnableAPITeamDeletion {
|
||||||
err = c.App.PermanentDeleteTeamId(c.Params.TeamId)
|
err = c.App.PermanentDeleteTeamId(c.Params.TeamId)
|
||||||
} else {
|
} else {
|
||||||
err = c.App.SoftDeleteTeam(c.Params.TeamId)
|
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 := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_OPEN}
|
||||||
team, _ = Client.CreateTeam(team)
|
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)
|
ok, resp := Client.PermanentDeleteTeam(team.Id)
|
||||||
CheckNoError(t, resp)
|
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)
|
rteam, err := th.App.GetTeam(team.Id)
|
||||||
if err != nil {
|
assert.Nil(t, err)
|
||||||
t.Fatal("should have returned archived team")
|
assert.True(t, rteam.DeleteAt > 0)
|
||||||
}
|
|
||||||
if rteam.DeleteAt == 0 {
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableAPITeamDeletion = true })
|
||||||
t.Fatal("should have not set to zero")
|
|
||||||
}
|
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")
|
ok, resp = Client.PermanentDeleteTeam("junk")
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|||||||
@@ -62,7 +62,8 @@
|
|||||||
"ExperimentalGroupUnreadChannels": "disabled",
|
"ExperimentalGroupUnreadChannels": "disabled",
|
||||||
"ImageProxyType": "",
|
"ImageProxyType": "",
|
||||||
"ImageProxyOptions": "",
|
"ImageProxyOptions": "",
|
||||||
"ImageProxyURL": ""
|
"ImageProxyURL": "",
|
||||||
|
"EnableAPITeamDeletion": false
|
||||||
},
|
},
|
||||||
"TeamSettings": {
|
"TeamSettings": {
|
||||||
"SiteName": "Mattermost",
|
"SiteName": "Mattermost",
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ type ServiceSettings struct {
|
|||||||
ImageProxyType *string
|
ImageProxyType *string
|
||||||
ImageProxyURL *string
|
ImageProxyURL *string
|
||||||
ImageProxyOptions *string
|
ImageProxyOptions *string
|
||||||
|
EnableAPITeamDeletion *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceSettings) SetDefaults() {
|
func (s *ServiceSettings) SetDefaults() {
|
||||||
@@ -452,6 +453,10 @@ func (s *ServiceSettings) SetDefaults() {
|
|||||||
if s.ImageProxyOptions == nil {
|
if s.ImageProxyOptions == nil {
|
||||||
s.ImageProxyOptions = NewString("")
|
s.ImageProxyOptions = NewString("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.EnableAPITeamDeletion == nil {
|
||||||
|
s.EnableAPITeamDeletion = NewBool(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClusterSettings struct {
|
type ClusterSettings struct {
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ func ParamsFromRequest(r *http.Request) *Params {
|
|||||||
params.Page = val
|
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
|
params.Permanent = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user