Migration of ChannelStore.GetMoreChannels to return plain error (#14811)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4a974eabea
Коммит
d391fd6231
@@ -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) {
|
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) {
|
func (a *App) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError) {
|
||||||
|
|||||||
@@ -3046,6 +3046,10 @@
|
|||||||
"id": "app.channel.get_deleted.missing.app_error",
|
"id": "app.channel.get_deleted.missing.app_error",
|
||||||
"translation": "No deleted channels exist."
|
"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",
|
"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."
|
"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",
|
"id": "store.sql_channel.get_members_by_ids.app_error",
|
||||||
"translation": "Unable to get the channel members."
|
"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",
|
"id": "store.sql_channel.get_pinnedpost_count.app_error",
|
||||||
"translation": "Unable to get the channel pinned post count."
|
"translation": "Unable to get the channel pinned post count."
|
||||||
|
|||||||
@@ -1219,7 +1219,7 @@ func (s *OpenTracingLayerChannelStore) GetMembersForUserWithPagination(teamId st
|
|||||||
return resultVar0, resultVar1
|
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()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMoreChannels")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ChannelStore.GetMoreChannels")
|
||||||
s.Root.Store.SetContext(newCtx)
|
s.Root.Store.SetContext(newCtx)
|
||||||
|
|||||||
@@ -999,7 +999,7 @@ func (s SqlChannelStore) getAllChannelsQuery(opts store.ChannelSearchOpts, forCo
|
|||||||
return query
|
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{}
|
channels := &model.ChannelList{}
|
||||||
_, err := s.GetReplica().Select(channels, `
|
_, err := s.GetReplica().Select(channels, `
|
||||||
SELECT
|
SELECT
|
||||||
@@ -1035,7 +1035,7 @@ func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset in
|
|||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
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
|
return channels, nil
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ type ChannelStore interface {
|
|||||||
GetChannels(teamId string, userId string, includeDeleted bool) (*model.ChannelList, error)
|
GetChannels(teamId string, userId string, includeDeleted bool) (*model.ChannelList, error)
|
||||||
GetAllChannels(page, perPage int, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, error)
|
GetAllChannels(page, perPage int, opts ChannelSearchOpts) (*model.ChannelListWithTeamData, error)
|
||||||
GetAllChannelsCount(opts ChannelSearchOpts) (int64, 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)
|
GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||||
GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError)
|
GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError)
|
||||||
GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, *model.AppError)
|
GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, *model.AppError)
|
||||||
|
|||||||
@@ -614,8 +614,8 @@ func testChannelStoreDelete(t *testing.T, ss store.Store) {
|
|||||||
require.Nil(t, nErr)
|
require.Nil(t, nErr)
|
||||||
require.Len(t, *list, 1, "invalid number of channels")
|
require.Len(t, *list, 1, "invalid number of channels")
|
||||||
|
|
||||||
list, err = ss.Channel().GetMoreChannels(o1.TeamId, m1.UserId, 0, 100)
|
list, nErr = ss.Channel().GetMoreChannels(o1.TeamId, m1.UserId, 0, 100)
|
||||||
require.Nil(t, err)
|
require.Nil(t, nErr)
|
||||||
require.Len(t, *list, 1, "invalid number of channels")
|
require.Len(t, *list, 1, "invalid number of channels")
|
||||||
|
|
||||||
cresult := ss.Channel().PermanentDelete(o2.Id)
|
cresult := ss.Channel().PermanentDelete(o2.Id)
|
||||||
|
|||||||
@@ -981,7 +981,7 @@ func (_m *ChannelStore) GetMembersForUserWithPagination(teamId string, userId st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMoreChannels provides a mock function with given fields: teamId, userId, offset, limit
|
// 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)
|
ret := _m.Called(teamId, userId, offset, limit)
|
||||||
|
|
||||||
var r0 *model.ChannelList
|
var r0 *model.ChannelList
|
||||||
@@ -993,13 +993,11 @@ func (_m *ChannelStore) GetMoreChannels(teamId string, userId string, offset int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var r1 *model.AppError
|
var r1 error
|
||||||
if rf, ok := ret.Get(1).(func(string, string, int, int) *model.AppError); ok {
|
if rf, ok := ret.Get(1).(func(string, string, int, int) error); ok {
|
||||||
r1 = rf(teamId, userId, offset, limit)
|
r1 = rf(teamId, userId, offset, limit)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(1) != nil {
|
r1 = ret.Error(1)
|
||||||
r1 = ret.Get(1).(*model.AppError)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0, r1
|
return r0, r1
|
||||||
|
|||||||
@@ -1128,7 +1128,7 @@ func (s *TimerLayerChannelStore) GetMembersForUserWithPagination(teamId string,
|
|||||||
return resultVar0, resultVar1
|
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()
|
start := timemodule.Now()
|
||||||
|
|
||||||
resultVar0, resultVar1 := s.ChannelStore.GetMoreChannels(teamId, userId, offset, limit)
|
resultVar0, resultVar1 := s.ChannelStore.GetMoreChannels(teamId, userId, offset, limit)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user