Migration of ChannelStore.GetMoreChannels to return plain error (#14811)

Automatic Merge
This commit is contained in:
Rodrigo Villablanca
2020-06-19 14:26:35 -04:00
committed by GitHub
parent 4a974eabea
commit d391fd6231
8 changed files with 20 additions and 18 deletions

View File

@@ -1619,7 +1619,11 @@ func (a *App) GetDeletedChannels(teamId string, offset int, limit int, userId st
}
func (a *App) GetChannelsUserNotIn(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
return a.Srv().Store.Channel().GetMoreChannels(teamId, userId, offset, limit)
channels, err := a.Srv().Store.Channel().GetMoreChannels(teamId, userId, offset, limit)
if err != nil {
return nil, model.NewAppError("GetChannelsUserNotIn", "app.channel.get_more_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return channels, nil
}
func (a *App) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError) {

View File

@@ -3046,6 +3046,10 @@
"id": "app.channel.get_deleted.missing.app_error",
"translation": "No deleted channels exist."
},
{
"id": "app.channel.get_more_channels.get.app_error",
"translation": "Unable to get the channels."
},
{
"id": "app.channel.move_channel.members_do_not_match.error",
"translation": "Unable to move a channel unless all its members are already members of the destination team."
@@ -6246,10 +6250,6 @@
"id": "store.sql_channel.get_members_by_ids.app_error",
"translation": "Unable to get the channel members."
},
{
"id": "store.sql_channel.get_more_channels.get.app_error",
"translation": "Unable to get the channels."
},
{
"id": "store.sql_channel.get_pinnedpost_count.app_error",
"translation": "Unable to get the channel pinned post count."

View File

@@ -1219,7 +1219,7 @@ func (s *OpenTracingLayerChannelStore) GetMembersForUserWithPagination(teamId st
return resultVar0, resultVar1
}
func (s *OpenTracingLayerChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
func (s *OpenTracingLayerChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, error) {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMoreChannels")
s.Root.Store.SetContext(newCtx)

View File

@@ -999,7 +999,7 @@ func (s SqlChannelStore) getAllChannelsQuery(opts store.ChannelSearchOpts, forCo
return query
}
func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, error) {
channels := &model.ChannelList{}
_, err := s.GetReplica().Select(channels, `
SELECT
@@ -1035,7 +1035,7 @@ func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset in
})
if err != nil {
return nil, model.NewAppError("SqlChannelStore.GetMoreChannels", "store.sql_channel.get_more_channels.get.app_error", nil, "teamId="+teamId+", userId="+userId+", err="+err.Error(), http.StatusInternalServerError)
return nil, errors.Wrapf(err, "failed getting channels with teamId=%s and userId=%s", teamId, userId)
}
return channels, nil

View File

@@ -151,7 +151,7 @@ type ChannelStore interface {
GetChannels(teamId string, userId string, includeDeleted bool) (*model.ChannelList, error)
GetAllChannels(page, perPage int, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, error)
GetAllChannelsCount(opts ChannelSearchOpts) (int64, error)
GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError)
GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, error)
GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError)
GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError)
GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, *model.AppError)

View File

@@ -614,8 +614,8 @@ func testChannelStoreDelete(t *testing.T, ss store.Store) {
require.Nil(t, nErr)
require.Len(t, *list, 1, "invalid number of channels")
list, err = ss.Channel().GetMoreChannels(o1.TeamId, m1.UserId, 0, 100)
require.Nil(t, err)
list, nErr = ss.Channel().GetMoreChannels(o1.TeamId, m1.UserId, 0, 100)
require.Nil(t, nErr)
require.Len(t, *list, 1, "invalid number of channels")
cresult := ss.Channel().PermanentDelete(o2.Id)

View File

@@ -981,7 +981,7 @@ func (_m *ChannelStore) GetMembersForUserWithPagination(teamId string, userId st
}
// GetMoreChannels provides a mock function with given fields: teamId, userId, offset, limit
func (_m *ChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
func (_m *ChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, error) {
ret := _m.Called(teamId, userId, offset, limit)
var r0 *model.ChannelList
@@ -993,13 +993,11 @@ func (_m *ChannelStore) GetMoreChannels(teamId string, userId string, offset int
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, int, int) *model.AppError); ok {
var r1 error
if rf, ok := ret.Get(1).(func(string, string, int, int) error); ok {
r1 = rf(teamId, userId, offset, limit)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
r1 = ret.Error(1)
}
return r0, r1

View File

@@ -1128,7 +1128,7 @@ func (s *TimerLayerChannelStore) GetMembersForUserWithPagination(teamId string,
return resultVar0, resultVar1
}
func (s *TimerLayerChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
func (s *TimerLayerChannelStore) GetMoreChannels(teamId string, userId string, offset int, limit int) (*model.ChannelList, error) {
start := timemodule.Now()
resultVar0, resultVar1 := s.ChannelStore.GetMoreChannels(teamId, userId, offset, limit)