X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fcontrollers%2Ffeeds.ts;h=08f179509e1747bcfb83207e2fa3f0a515747799;hb=8be1afa12b700b93ed92365cab05c0ef81d643aa;hp=4a4dc3820a81b2ec480c03de67ff0f9fc751dc43;hpb=9309c3df8fffe5f307e48a35484d752440cf852d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index 4a4dc3820..08f179509 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts @@ -3,10 +3,9 @@ import { CONFIG, FEEDS } from '../initializers/constants' import { asyncMiddleware, feedsValidator, setDefaultSort, videosSortValidator } from '../middlewares' import { VideoModel } from '../models/video/video' import * as Feed from 'pfeed' -import { ResultList } from '../../shared/models' import { AccountModel } from '../models/account/account' import { cacheRoute } from '../middlewares/cache' -import { VideoSortField } from '../../client/src/app/shared/video/sort-field.type' +import { VideoChannelModel } from '../models/video/video-channel' const feedsRouter = express.Router() @@ -30,29 +29,20 @@ async function generateFeed (req: express.Request, res: express.Response, next: let feed = initFeed() const start = 0 - let resultList: ResultList const account: AccountModel = res.locals.account + const videoChannel: VideoChannelModel = res.locals.videoChannel const hideNSFW = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY === 'do_not_list' - if (account) { - resultList = await VideoModel.listAccountVideosForApi( - account.id, - start, - FEEDS.COUNT, - req.query.sort as VideoSortField, - hideNSFW, - true - ) - } else { - resultList = await VideoModel.listForApi( - start, - FEEDS.COUNT, - req.query.sort as VideoSortField, - hideNSFW, - req.query.filter, - true - ) - } + const resultList = await VideoModel.listForApi({ + start, + count: FEEDS.COUNT, + sort: req.query.sort, + hideNSFW, + filter: req.query.filter, + withFiles: true, + accountId: account ? account.id : null, + videoChannelId: videoChannel ? videoChannel.id : null + }) // Adding video items to the feed, one at a time resultList.data.forEach(video => {