diff --git a/app/user.go b/app/user.go index 45105578ac..eab68c4372 100644 --- a/app/user.go +++ b/app/user.go @@ -1462,8 +1462,8 @@ func (a *App) PermanentDeleteUser(user *model.User) *model.AppError { return err } - if result := <-a.Srv.Store.Channel().PermanentDeleteMembersByUser(user.Id); result.Err != nil { - return result.Err + if err := a.Srv.Store.Channel().PermanentDeleteMembersByUser(user.Id); err != nil { + return err } if err := a.Srv.Store.Post().PermanentDeleteByUser(user.Id); err != nil { diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index 0c070b3b8f..244d35025d 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -1717,12 +1717,11 @@ func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.Ap return nil } -func (s SqlChannelStore) PermanentDeleteMembersByUser(userId string) store.StoreChannel { - return store.Do(func(result *store.StoreResult) { - if _, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE UserId = :UserId", map[string]interface{}{"UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlChannelStore.RemoveMember", "store.sql_channel.permanent_delete_members_by_user.app_error", nil, "user_id="+userId+", "+err.Error(), http.StatusInternalServerError) - } - }) +func (s SqlChannelStore) PermanentDeleteMembersByUser(userId string) *model.AppError { + if _, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE UserId = :UserId", map[string]interface{}{"UserId": userId}); err != nil { + return model.NewAppError("SqlChannelStore.RemoveMember", "store.sql_channel.permanent_delete_members_by_user.app_error", nil, "user_id="+userId+", "+err.Error(), http.StatusInternalServerError) + } + return nil } func (s SqlChannelStore) UpdateLastViewedAt(channelIds []string, userId string) (map[string]int64, *model.AppError) { diff --git a/store/store.go b/store/store.go index 7980b6d5c3..c513c51ac0 100644 --- a/store/store.go +++ b/store/store.go @@ -174,7 +174,7 @@ type ChannelStore interface { GetMemberCount(channelId string, allowFromCache bool) (int64, *model.AppError) GetPinnedPosts(channelId string) StoreChannel RemoveMember(channelId string, userId string) *model.AppError - PermanentDeleteMembersByUser(userId string) StoreChannel + PermanentDeleteMembersByUser(userId string) *model.AppError PermanentDeleteMembersByChannel(channelId string) *model.AppError UpdateLastViewedAt(channelIds []string, userId string) (map[string]int64, *model.AppError) IncrementMentionCount(channelId string, userId string) *model.AppError diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index c936880211..7c0da9347a 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -984,7 +984,8 @@ func testChannelDeleteMemberStore(t *testing.T, ss store.Store) { t.Fatal("should have saved 2 members") } - store.Must(ss.Channel().PermanentDeleteMembersByUser(o2.UserId)) + err = ss.Channel().PermanentDeleteMembersByUser(o2.UserId) + require.Nil(t, err) count, err = ss.Channel().GetMemberCount(o1.ChannelId, false) require.Nil(t, err) diff --git a/store/storetest/mocks/ChannelStore.go b/store/storetest/mocks/ChannelStore.go index 6692b0572e..13ce11f6d9 100644 --- a/store/storetest/mocks/ChannelStore.go +++ b/store/storetest/mocks/ChannelStore.go @@ -1163,15 +1163,15 @@ func (_m *ChannelStore) PermanentDeleteMembersByChannel(channelId string) *model } // PermanentDeleteMembersByUser provides a mock function with given fields: userId -func (_m *ChannelStore) PermanentDeleteMembersByUser(userId string) store.StoreChannel { +func (_m *ChannelStore) PermanentDeleteMembersByUser(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) } }