X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Ffeeds.ts;h=92cf85050da42cbf52e34a28613ab6b639c4ce7b;hb=0f320037e689b2778959c12ddd4ce790f6e4ae4f;hp=6a6af3e0910f9d50d4ebb17a29e97fb475098445;hpb=0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index 6a6af3e09..92cf85050 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts @@ -1,20 +1,19 @@ import * as express from 'express' -import { CONFIG, FEEDS } from '../initializers/constants' +import { CONFIG, FEEDS, ROUTE_CACHE_LIFETIME } 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() feedsRouter.get('/feeds/videos.:format', videosSortValidator, setDefaultSort, + asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS)), asyncMiddleware(feedsValidator), - asyncMiddleware(cacheRoute), asyncMiddleware(generateFeed) ) @@ -31,17 +30,19 @@ async function generateFeed (req: express.Request, res: express.Response, next: const start = 0 const account: AccountModel = res.locals.account + const videoChannel: VideoChannelModel = res.locals.videoChannel const hideNSFW = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY === 'do_not_list' - const resultList = await VideoModel.listForApi( + const resultList = await VideoModel.listForApi({ start, - FEEDS.COUNT, - req.query.sort as VideoSortField, + count: FEEDS.COUNT, + sort: req.query.sort, hideNSFW, - req.query.filter, - true, - account ? account.id : null - ) + 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 => {