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

Этот коммит содержится в:
Puneeth Reddy
2019-04-29 01:42:33 -07:00
коммит произвёл Miguel de la Cruz
родитель 171058eb3d
Коммит dec3c8facb
5 изменённых файлов: 16 добавлений и 16 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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