]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/feeds.ts
Move middleware utils in middlewares
[github/Chocobozzz/PeerTube.git] / server / controllers / feeds.ts
index e29a8fe1db9ee28efd7900935e6a7ac8d14c7943..865f5c2a129006c7ca7422bbb499ac2af0a8226f 100644 (file)
@@ -1,8 +1,9 @@
 import * as express from 'express'
 import * as Feed from 'pfeed'
+import { VideoFilter } from '../../shared/models/videos/video-query.type'
 import { buildNSFWFilter } from '../helpers/express-utils'
 import { CONFIG } from '../initializers/config'
-import { FEEDS, ROUTE_CACHE_LIFETIME, THUMBNAILS_SIZE, WEBSERVER } from '../initializers/constants'
+import { FEEDS, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
 import {
   asyncMiddleware,
   commonVideosFiltersValidator,
@@ -17,7 +18,6 @@ import {
 import { cacheRoute } from '../middlewares/cache'
 import { VideoModel } from '../models/video/video'
 import { VideoCommentModel } from '../models/video/video-comment'
-import { VideoFilter } from '../../shared/models/videos/video-query.type'
 
 const feedsRouter = express.Router()
 
@@ -167,7 +167,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
     videoChannelId: videoChannel ? videoChannel.id : null
   }
 
-  const resultList = await VideoModel.listForApi({
+  const { data } = await VideoModel.listForApi({
     start,
     count: FEEDS.COUNT,
     sort: req.query.sort,
@@ -175,10 +175,11 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
     nsfw,
     filter: req.query.filter as VideoFilter,
     withFiles: true,
+    countVideos: false,
     ...options
   })
 
-  addVideosToFeed(feed, resultList.data)
+  addVideosToFeed(feed, data)
 
   // Now the feed generation is done, let's send it!
   return sendFeed(feed, req, res)
@@ -198,20 +199,22 @@ async function generateVideoFeedForSubscriptions (req: express.Request, res: exp
     queryString: new URL(WEBSERVER.URL + req.url).search
   })
 
-  const resultList = await VideoModel.listForApi({
+  const { data } = await VideoModel.listForApi({
     start,
     count: FEEDS.COUNT,
     sort: req.query.sort,
     includeLocalVideos: false,
     nsfw,
     filter: req.query.filter as VideoFilter,
+
     withFiles: true,
+    countVideos: false,
 
     followerActorId: res.locals.user.Account.Actor.id,
     user: res.locals.user
   })
 
-  addVideosToFeed(feed, resultList.data)
+  addVideosToFeed(feed, data)
 
   // Now the feed generation is done, let's send it!
   return sendFeed(feed, req, res)
@@ -290,7 +293,7 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
     feed.addItem({
       title: video.name,
       id: video.url,
-      link: WEBSERVER.URL + '/videos/watch/' + video.uuid,
+      link: WEBSERVER.URL + '/w/' + video.uuid,
       description: video.getTruncatedDescription(),
       content: video.description,
       author: [
@@ -318,9 +321,9 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
       },
       thumbnail: [
         {
-          url: WEBSERVER.URL + video.getMiniatureStaticPath(),
-          height: THUMBNAILS_SIZE.height,
-          width: THUMBNAILS_SIZE.width
+          url: WEBSERVER.URL + video.getPreviewStaticPath(),
+          height: PREVIEWS_SIZE.height,
+          width: PREVIEWS_SIZE.width
         }
       ]
     })