diff --git a/app/channel.go b/app/channel.go index bdc1ad5bd6..9e2cd70767 100644 --- a/app/channel.go +++ b/app/channel.go @@ -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 { diff --git a/store/sqlstore/post_store.go b/store/sqlstore/post_store.go index fd5c9a229b..b5e1852519 100644 --- a/store/sqlstore/post_store.go +++ b/store/sqlstore/post_store.go @@ -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 { diff --git a/store/store.go b/store/store.go index 9ea14f7be2..8272649c5b 100644 --- a/store/store.go +++ b/store/store.go @@ -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 diff --git a/store/storetest/mocks/PostStore.go b/store/storetest/mocks/PostStore.go index a515b3f436..065e2b183d 100644 --- a/store/storetest/mocks/PostStore.go +++ b/store/storetest/mocks/PostStore.go @@ -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) } } diff --git a/store/storetest/post_store.go b/store/storetest/post_store.go index 80a3e03755..aa5f988a54 100644 --- a/store/storetest/post_store.go +++ b/store/storetest/post_store.go @@ -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 {