migrating perm delete by channel to sync (#10993)
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
ca15690685
Коммит
42ac975c0e
@@ -1933,8 +1933,8 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
|
|||||||
return channelUsers.Err
|
return channelUsers.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
if result := <-a.Srv.Store.Post().PermanentDeleteByChannel(channel.Id); result.Err != nil {
|
if err := a.Srv.Store.Post().PermanentDeleteByChannel(channel.Id); err != nil {
|
||||||
return result.Err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if result := <-a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); result.Err != nil {
|
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 {
|
func (s *SqlPostStore) PermanentDeleteByChannel(channelId string) *model.AppError {
|
||||||
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 {
|
||||||
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)
|
||||||
result.Err = 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 {
|
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
|
GetSingle(id string) StoreChannel
|
||||||
Delete(postId string, time int64, deleteByID string) *model.AppError
|
Delete(postId string, time int64, deleteByID string) *model.AppError
|
||||||
PermanentDeleteByUser(userId string) StoreChannel
|
PermanentDeleteByUser(userId string) StoreChannel
|
||||||
PermanentDeleteByChannel(channelId string) StoreChannel
|
PermanentDeleteByChannel(channelId string) *model.AppError
|
||||||
GetPosts(channelId string, offset int, limit int, allowFromCache bool) StoreChannel
|
GetPosts(channelId string, offset int, limit int, allowFromCache bool) StoreChannel
|
||||||
GetFlaggedPosts(userId string, offset int, limit int) StoreChannel
|
GetFlaggedPosts(userId string, offset int, limit int) StoreChannel
|
||||||
GetFlaggedPostsForTeam(userId, teamId 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
|
// 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)
|
ret := _m.Called(channelId)
|
||||||
|
|
||||||
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(channelId)
|
r0 = rf(channelId)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
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")
|
t.Fatal("Deleted id should have failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if r2 := <-ss.Post().PermanentDeleteByChannel(o3.ChannelId); r2.Err != nil {
|
if err := ss.Post().PermanentDeleteByChannel(o3.ChannelId); err != nil {
|
||||||
t.Fatal(r2.Err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := ss.Post().Get(o3.Id); err == nil {
|
if _, err := ss.Post().Get(o3.Id); err == nil {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user