]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/feeds.ts
Limit user tokens cache
[github/Chocobozzz/PeerTube.git] / server / controllers / feeds.ts
index 682f4abdaf873d56087f4b8b242b8afa0066e487..cd46b6e0f62792d9ad367a93e1b80d93279cf863 100644 (file)
@@ -1,12 +1,17 @@
 import * as express from 'express'
 import { CONFIG, FEEDS, ROUTE_CACHE_LIFETIME } from '../initializers/constants'
 import { THUMBNAILS_SIZE } from '../initializers'
-import { asyncMiddleware, setDefaultSort, videoCommentsFeedsValidator, videoFeedsValidator, videosSortValidator } from '../middlewares'
+import {
+  asyncMiddleware,
+  commonVideosFiltersValidator,
+  setDefaultSort,
+  videoCommentsFeedsValidator,
+  videoFeedsValidator,
+  videosSortValidator
+} from '../middlewares'
 import { VideoModel } from '../models/video/video'
 import * as Feed from 'pfeed'
-import { AccountModel } from '../models/account/account'
 import { cacheRoute } from '../middlewares/cache'
-import { VideoChannelModel } from '../models/video/video-channel'
 import { VideoCommentModel } from '../models/video/video-comment'
 import { buildNSFWFilter } from '../helpers/express-utils'
 
@@ -22,6 +27,7 @@ feedsRouter.get('/feeds/videos.:format',
   videosSortValidator,
   setDefaultSort,
   asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS)),
+  commonVideosFiltersValidator,
   asyncMiddleware(videoFeedsValidator),
   asyncMiddleware(generateVideoFeed)
 )
@@ -34,10 +40,10 @@ export {
 
 // ---------------------------------------------------------------------------
 
-async function generateVideoCommentsFeed (req: express.Request, res: express.Response, next: express.NextFunction) {
+async function generateVideoCommentsFeed (req: express.Request, res: express.Response) {
   const start = 0
 
-  const video = res.locals.video as VideoModel
+  const video = res.locals.video
   const videoId: number = video ? video.id : undefined
 
   const comments = await VideoCommentModel.listForFeed(start, FEEDS.COUNT, videoId)
@@ -48,7 +54,7 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res
 
   // Adding video items to the feed, one at a time
   comments.forEach(comment => {
-    const link = CONFIG.WEBSERVER.URL + '/videos/watch/' + comment.Video.uuid + ';threadId=' + comment.getThreadId()
+    const link = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath()
 
     feed.addItem({
       title: `${comment.Video.name} - ${comment.Account.getDisplayName()}`,
@@ -69,11 +75,11 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res
   return sendFeed(feed, req, res)
 }
 
-async function generateVideoFeed (req: express.Request, res: express.Response, next: express.NextFunction) {
+async function generateVideoFeed (req: express.Request, res: express.Response) {
   const start = 0
 
-  const account: AccountModel = res.locals.account
-  const videoChannel: VideoChannelModel = res.locals.videoChannel
+  const account = res.locals.account
+  const videoChannel = res.locals.videoChannel
   const nsfw = buildNSFWFilter(res, req.query.nsfw)
 
   let name: string
@@ -96,6 +102,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response, n
     start,
     count: FEEDS.COUNT,
     sort: req.query.sort,
+    includeLocalVideos: true,
     nsfw,
     filter: req.query.filter,
     withFiles: true,