mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-15293: migrate commandstore.PermanentDeleteByUser to sync by default (#10744)
This commit is contained in:
committed by
Miguel de la Cruz
parent
171058eb3d
commit
dec3c8facb
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user