MM-25563: Add endpoint to fetch only archived channels (#15031)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
29c8b58fc7
Коммит
77f7a97bee
@@ -513,7 +513,7 @@ type AppIface interface {
|
||||
GetChannelsByNames(channelNames []string, teamId string) ([]*model.Channel, *model.AppError)
|
||||
GetChannelsForScheme(scheme *model.Scheme, offset int, limit int) (model.ChannelList, *model.AppError)
|
||||
GetChannelsForSchemePage(scheme *model.Scheme, page int, perPage int) (model.ChannelList, *model.AppError)
|
||||
GetChannelsForUser(teamId string, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
||||
GetChannelsForUser(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError)
|
||||
GetChannelsUserNotIn(teamId string, userId string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetClusterId() string
|
||||
GetClusterStatus() []*model.ClusterInfo
|
||||
|
||||
@@ -1554,8 +1554,8 @@ func (a *App) GetChannelByNameForTeamName(channelName, teamName string, includeD
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (a *App) GetChannelsForUser(teamId string, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetChannels(teamId, userId, includeDeleted)
|
||||
func (a *App) GetChannelsForUser(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError) {
|
||||
list, err := a.Srv().Store.Channel().GetChannels(teamId, userId, includeDeleted, lastDeleteAt)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
|
||||
@@ -944,19 +944,19 @@ func TestGetChannelsForUser(t *testing.T) {
|
||||
defer th.App.PermanentDeleteChannel(channel)
|
||||
defer th.TearDown()
|
||||
|
||||
channelList, err := th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, false)
|
||||
channelList, err := th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, false, 0)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelList, 4)
|
||||
|
||||
th.App.DeleteChannel(channel, th.BasicUser.Id)
|
||||
|
||||
// Now we get all the non-archived channels for the user
|
||||
channelList, err = th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, false)
|
||||
channelList, err = th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, false, 0)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelList, 3)
|
||||
|
||||
// Now we get all the channels, even though are archived, for the user
|
||||
channelList, err = th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, true)
|
||||
channelList, err = th.App.GetChannelsForUser(th.BasicTeam.Id, th.BasicUser.Id, true, 0)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelList, 4)
|
||||
}
|
||||
|
||||
@@ -4650,7 +4650,7 @@ func (a *OpenTracingAppLayer) GetChannelsForSchemePage(scheme *model.Scheme, pag
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetChannelsForUser(teamId string, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetChannelsForUser(teamId string, userId string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelsForUser")
|
||||
|
||||
@@ -4662,7 +4662,7 @@ func (a *OpenTracingAppLayer) GetChannelsForUser(teamId string, userId string, i
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetChannelsForUser(teamId, userId, includeDeleted)
|
||||
resultVar0, resultVar1 := a.app.GetChannelsForUser(teamId, userId, includeDeleted, lastDeleteAt)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
|
||||
@@ -374,7 +374,7 @@ func (api *PluginAPI) GetChannelByNameForTeamName(teamName, channelName string,
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) ([]*model.Channel, *model.AppError) {
|
||||
channels, err := api.app.GetChannelsForUser(teamId, userId, includeDeleted)
|
||||
channels, err := api.app.GetChannelsForUser(teamId, userId, includeDeleted, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1003,7 +1003,7 @@ func (a *App) LeaveTeam(team *model.Team, user *model.User, requestorId string)
|
||||
var channelList *model.ChannelList
|
||||
|
||||
var nErr error
|
||||
if channelList, nErr = a.Srv().Store.Channel().GetChannels(team.Id, user.Id, true); nErr != nil {
|
||||
if channelList, nErr = a.Srv().Store.Channel().GetChannels(team.Id, user.Id, true, 0); nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
if errors.As(nErr, &nfErr) {
|
||||
channelList = &model.ChannelList{}
|
||||
|
||||
@@ -966,7 +966,7 @@ func (a *App) invalidateUserChannelMembersCaches(userId string) *model.AppError
|
||||
}
|
||||
|
||||
for _, team := range teamsForUser {
|
||||
channelsForUser, err := a.GetChannelsForUser(team.Id, userId, false)
|
||||
channelsForUser, err := a.GetChannelsForUser(team.Id, userId, false, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user