X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fcontrollers%2Ffeeds.ts;h=435b12193a9bee8fc0cf823aa0ec8f7be73dbdd3;hb=79db409a41bd28fd2773626c9a93b5d326a38bc0;hp=2182b42f56976df03a019749e09869f817bd2e3c;hpb=18490b07650d77d7fe376970b749af5a8c672fd6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index 2182b42f5..435b12193 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts @@ -1,8 +1,10 @@ import * as express from 'express' import * as Feed from 'pfeed' +import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' +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 +19,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 +168,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 +176,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 +200,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) @@ -255,7 +259,7 @@ function addVideosToFeed (feed, videos: VideoModel[]) { * Adding video items to the feed object, one at a time */ for (const video of videos) { - const formattedVideoFiles = video.getFormattedVideoFilesJSON() + const formattedVideoFiles = video.getFormattedVideoFilesJSON(false) const torrents = formattedVideoFiles.map(videoFile => ({ title: video.name, @@ -283,14 +287,14 @@ function addVideosToFeed (feed, videos: VideoModel[]) { if (video.category) { categories.push({ value: video.category, - label: VideoModel.getCategoryLabel(video.category) + label: getCategoryLabel(video.category) }) } 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 +322,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 } ] })