diff --git a/app/team.go b/app/team.go index 79227a915c..1c091abd1b 100644 --- a/app/team.go +++ b/app/team.go @@ -1105,8 +1105,8 @@ func (a *App) PermanentDeleteTeam(team *model.Team) *model.AppError { return result.Err } - if result := <-a.Srv.Store.Command().PermanentDeleteByTeam(team.Id); result.Err != nil { - return result.Err + if err := a.Srv.Store.Command().PermanentDeleteByTeam(team.Id); err != nil { + return err } if result := <-a.Srv.Store.Team().PermanentDelete(team.Id); result.Err != nil { diff --git a/store/sqlstore/command_store.go b/store/sqlstore/command_store.go index 7527e8471d..e2c3b6a115 100644 --- a/store/sqlstore/command_store.go +++ b/store/sqlstore/command_store.go @@ -111,13 +111,12 @@ func (s SqlCommandStore) Delete(commandId string, time int64) store.StoreChannel }) } -func (s SqlCommandStore) PermanentDeleteByTeam(teamId string) store.StoreChannel { - return store.Do(func(result *store.StoreResult) { - _, err := s.GetMaster().Exec("DELETE FROM Commands WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}) - if err != nil { - result.Err = model.NewAppError("SqlCommandStore.DeleteByTeam", "store.sql_command.save.delete_perm.app_error", nil, "id="+teamId+", err="+err.Error(), http.StatusInternalServerError) - } - }) +func (s SqlCommandStore) PermanentDeleteByTeam(teamId string) *model.AppError { + _, err := s.GetMaster().Exec("DELETE FROM Commands WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}) + if err != nil { + return model.NewAppError("SqlCommandStore.DeleteByTeam", "store.sql_command.save.delete_perm.app_error", nil, "id="+teamId+", err="+err.Error(), http.StatusInternalServerError) + } + return nil } func (s SqlCommandStore) PermanentDeleteByUser(userId string) *model.AppError { diff --git a/store/store.go b/store/store.go index f176f4dfba..b3518a3d5f 100644 --- a/store/store.go +++ b/store/store.go @@ -414,7 +414,7 @@ type CommandStore interface { GetByTeam(teamId string) ([]*model.Command, *model.AppError) GetByTrigger(teamId string, trigger string) StoreChannel Delete(commandId string, time int64) StoreChannel - PermanentDeleteByTeam(teamId string) StoreChannel + PermanentDeleteByTeam(teamId string) *model.AppError PermanentDeleteByUser(userId string) *model.AppError Update(hook *model.Command) (*model.Command, *model.AppError) AnalyticsCommandCount(teamId string) StoreChannel diff --git a/store/storetest/command_store.go b/store/storetest/command_store.go index a1a7b0824e..a2b0f0f860 100644 --- a/store/storetest/command_store.go +++ b/store/storetest/command_store.go @@ -186,8 +186,8 @@ func testCommandStoreDeleteByTeam(t *testing.T, ss store.Store) { } } - if r2 := <-ss.Command().PermanentDeleteByTeam(o1.TeamId); r2.Err != nil { - t.Fatal(r2.Err) + if err := ss.Command().PermanentDeleteByTeam(o1.TeamId); err != nil { + t.Fatal(err) } if r3 := (<-ss.Command().Get(o1.Id)); r3.Err == nil { diff --git a/store/storetest/mocks/CommandStore.go b/store/storetest/mocks/CommandStore.go index 4accab949f..df432cecec 100644 --- a/store/storetest/mocks/CommandStore.go +++ b/store/storetest/mocks/CommandStore.go @@ -103,15 +103,15 @@ func (_m *CommandStore) GetByTrigger(teamId string, trigger string) store.StoreC } // PermanentDeleteByTeam provides a mock function with given fields: teamId -func (_m *CommandStore) PermanentDeleteByTeam(teamId string) store.StoreChannel { +func (_m *CommandStore) PermanentDeleteByTeam(teamId string) *model.AppError { ret := _m.Called(teamId) - var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok { + var r0 *model.AppError + if rf, ok := ret.Get(0).(func(string) *model.AppError); ok { r0 = rf(teamId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(store.StoreChannel) + r0 = ret.Get(0).(*model.AppError) } }