MM-15293: migrate commandstore.PermanentDeleteByUser to sync by default (#10744)

This commit is contained in:
Puneeth Reddy
2019-04-29 01:42:33 -07:00
committed by Miguel de la Cruz
parent 171058eb3d
commit dec3c8facb
5 changed files with 16 additions and 16 deletions

View File

@@ -1418,8 +1418,8 @@ func (a *App) PermanentDeleteUser(user *model.User) *model.AppError {
return err
}
if result := <-a.Srv.Store.Command().PermanentDeleteByUser(user.Id); result.Err != nil {
return result.Err
if err := a.Srv.Store.Command().PermanentDeleteByUser(user.Id); err != nil {
return err
}
if result := <-a.Srv.Store.Preference().PermanentDeleteByUser(user.Id); result.Err != nil {

View File

@@ -123,13 +123,13 @@ func (s SqlCommandStore) PermanentDeleteByTeam(teamId string) store.StoreChannel
})
}
func (s SqlCommandStore) PermanentDeleteByUser(userId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
_, err := s.GetMaster().Exec("DELETE FROM Commands WHERE CreatorId = :UserId", map[string]interface{}{"UserId": userId})
if err != nil {
result.Err = model.NewAppError("SqlCommandStore.DeleteByUser", "store.sql_command.save.delete_perm.app_error", nil, "id="+userId+", err="+err.Error(), http.StatusInternalServerError)
}
})
func (s SqlCommandStore) PermanentDeleteByUser(userId string) *model.AppError {
_, err := s.GetMaster().Exec("DELETE FROM Commands WHERE CreatorId = :UserId", map[string]interface{}{"UserId": userId})
if err != nil {
return model.NewAppError("SqlCommandStore.DeleteByUser", "store.sql_command.save.delete_perm.app_error", nil, "id="+userId+", err="+err.Error(), http.StatusInternalServerError)
}
return nil
}
func (s SqlCommandStore) Update(cmd *model.Command) store.StoreChannel {

View File

@@ -410,7 +410,7 @@ type CommandStore interface {
GetByTrigger(teamId string, trigger string) StoreChannel
Delete(commandId string, time int64) StoreChannel
PermanentDeleteByTeam(teamId string) StoreChannel
PermanentDeleteByUser(userId string) StoreChannel
PermanentDeleteByUser(userId string) *model.AppError
Update(hook *model.Command) StoreChannel
AnalyticsCommandCount(teamId string) StoreChannel
}

View File

@@ -196,8 +196,8 @@ func testCommandStoreDeleteByUser(t *testing.T, ss store.Store) {
}
}
if r2 := <-ss.Command().PermanentDeleteByUser(o1.CreatorId); r2.Err != nil {
t.Fatal(r2.Err)
if err := ss.Command().PermanentDeleteByUser(o1.CreatorId); err != nil {
t.Fatal(err)
}
if r3 := (<-ss.Command().Get(o1.Id)); r3.Err == nil {

View File

@@ -119,15 +119,15 @@ func (_m *CommandStore) PermanentDeleteByTeam(teamId string) store.StoreChannel
}
// PermanentDeleteByUser provides a mock function with given fields: userId
func (_m *CommandStore) PermanentDeleteByUser(userId string) store.StoreChannel {
func (_m *CommandStore) PermanentDeleteByUser(userId string) *model.AppError {
ret := _m.Called(userId)
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(userId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel)
r0 = ret.Get(0).(*model.AppError)
}
}