migrating perm delete by channel to sync (#10993)

Этот коммит содержится в:
Evan do Carmo
2019-05-29 08:55:03 -04:00
коммит произвёл Jesús Espino
родитель ca15690685
Коммит 42ac975c0e
5 изменённых файлов: 14 добавлений и 15 удалений

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

@@ -1933,8 +1933,8 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
return channelUsers.Err
}
if result := <-a.Srv.Store.Post().PermanentDeleteByChannel(channel.Id); result.Err != nil {
return result.Err
if err := a.Srv.Store.Post().PermanentDeleteByChannel(channel.Id); err != nil {
return err
}
if result := <-a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); result.Err != nil {

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

@@ -452,12 +452,11 @@ func (s *SqlPostStore) PermanentDeleteByUser(userId string) store.StoreChannel {
})
}
func (s *SqlPostStore) PermanentDeleteByChannel(channelId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
if _, err := s.GetMaster().Exec("DELETE FROM Posts WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId}); err != nil {
result.Err = model.NewAppError("SqlPostStore.PermanentDeleteByChannel", "store.sql_post.permanent_delete_by_channel.app_error", nil, "channel_id="+channelId+", "+err.Error(), http.StatusInternalServerError)
}
})
func (s *SqlPostStore) PermanentDeleteByChannel(channelId string) *model.AppError {
if _, err := s.GetMaster().Exec("DELETE FROM Posts WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId}); err != nil {
return model.NewAppError("SqlPostStore.PermanentDeleteByChannel", "store.sql_post.permanent_delete_by_channel.app_error", nil, "channel_id="+channelId+", "+err.Error(), http.StatusInternalServerError)
}
return nil
}
func (s *SqlPostStore) GetPosts(channelId string, offset int, limit int, allowFromCache bool) store.StoreChannel {

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

@@ -216,7 +216,7 @@ type PostStore interface {
GetSingle(id string) StoreChannel
Delete(postId string, time int64, deleteByID string) *model.AppError
PermanentDeleteByUser(userId string) StoreChannel
PermanentDeleteByChannel(channelId string) StoreChannel
PermanentDeleteByChannel(channelId string) *model.AppError
GetPosts(channelId string, offset int, limit int, allowFromCache bool) StoreChannel
GetFlaggedPosts(userId string, offset int, limit int) StoreChannel
GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) StoreChannel

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

@@ -424,15 +424,15 @@ func (_m *PostStore) PermanentDeleteBatch(endTime int64, limit int64) store.Stor
}
// PermanentDeleteByChannel provides a mock function with given fields: channelId
func (_m *PostStore) PermanentDeleteByChannel(channelId string) store.StoreChannel {
func (_m *PostStore) PermanentDeleteByChannel(channelId string) *model.AppError {
ret := _m.Called(channelId)
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(channelId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel)
r0 = ret.Get(0).(*model.AppError)
}
}

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

@@ -480,8 +480,8 @@ func testPostStorePermDelete1Level(t *testing.T, ss store.Store) {
t.Fatal("Deleted id should have failed")
}
if r2 := <-ss.Post().PermanentDeleteByChannel(o3.ChannelId); r2.Err != nil {
t.Fatal(r2.Err)
if err := ss.Post().PermanentDeleteByChannel(o3.ChannelId); err != nil {
t.Fatal(err)
}
if _, err := ss.Post().Get(o3.Id); err == nil {