diff options
Diffstat (limited to 'server/controllers/feeds.ts')
-rw-r--r-- | server/controllers/feeds.ts | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index 960085af1..d3f581615 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { CONFIG, FEEDS, ROUTE_CACHE_LIFETIME } from '../initializers/constants' | 2 | import { FEEDS, ROUTE_CACHE_LIFETIME, THUMBNAILS_SIZE, WEBSERVER } from '../initializers/constants' |
3 | import { THUMBNAILS_SIZE } from '../initializers' | ||
4 | import { | 3 | import { |
5 | asyncMiddleware, | 4 | asyncMiddleware, |
6 | commonVideosFiltersValidator, | 5 | commonVideosFiltersValidator, |
@@ -11,11 +10,10 @@ import { | |||
11 | } from '../middlewares' | 10 | } from '../middlewares' |
12 | import { VideoModel } from '../models/video/video' | 11 | import { VideoModel } from '../models/video/video' |
13 | import * as Feed from 'pfeed' | 12 | import * as Feed from 'pfeed' |
14 | import { AccountModel } from '../models/account/account' | ||
15 | import { cacheRoute } from '../middlewares/cache' | 13 | import { cacheRoute } from '../middlewares/cache' |
16 | import { VideoChannelModel } from '../models/video/video-channel' | ||
17 | import { VideoCommentModel } from '../models/video/video-comment' | 14 | import { VideoCommentModel } from '../models/video/video-comment' |
18 | import { buildNSFWFilter } from '../helpers/express-utils' | 15 | import { buildNSFWFilter } from '../helpers/express-utils' |
16 | import { CONFIG } from '../initializers/config' | ||
19 | 17 | ||
20 | const feedsRouter = express.Router() | 18 | const feedsRouter = express.Router() |
21 | 19 | ||
@@ -42,10 +40,10 @@ export { | |||
42 | 40 | ||
43 | // --------------------------------------------------------------------------- | 41 | // --------------------------------------------------------------------------- |
44 | 42 | ||
45 | async function generateVideoCommentsFeed (req: express.Request, res: express.Response, next: express.NextFunction) { | 43 | async function generateVideoCommentsFeed (req: express.Request, res: express.Response) { |
46 | const start = 0 | 44 | const start = 0 |
47 | 45 | ||
48 | const video = res.locals.video as VideoModel | 46 | const video = res.locals.video |
49 | const videoId: number = video ? video.id : undefined | 47 | const videoId: number = video ? video.id : undefined |
50 | 48 | ||
51 | const comments = await VideoCommentModel.listForFeed(start, FEEDS.COUNT, videoId) | 49 | const comments = await VideoCommentModel.listForFeed(start, FEEDS.COUNT, videoId) |
@@ -56,7 +54,7 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res | |||
56 | 54 | ||
57 | // Adding video items to the feed, one at a time | 55 | // Adding video items to the feed, one at a time |
58 | comments.forEach(comment => { | 56 | comments.forEach(comment => { |
59 | const link = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath() | 57 | const link = WEBSERVER.URL + comment.getCommentStaticPath() |
60 | 58 | ||
61 | feed.addItem({ | 59 | feed.addItem({ |
62 | title: `${comment.Video.name} - ${comment.Account.getDisplayName()}`, | 60 | title: `${comment.Video.name} - ${comment.Account.getDisplayName()}`, |
@@ -77,11 +75,11 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res | |||
77 | return sendFeed(feed, req, res) | 75 | return sendFeed(feed, req, res) |
78 | } | 76 | } |
79 | 77 | ||
80 | async function generateVideoFeed (req: express.Request, res: express.Response, next: express.NextFunction) { | 78 | async function generateVideoFeed (req: express.Request, res: express.Response) { |
81 | const start = 0 | 79 | const start = 0 |
82 | 80 | ||
83 | const account: AccountModel = res.locals.account | 81 | const account = res.locals.account |
84 | const videoChannel: VideoChannelModel = res.locals.videoChannel | 82 | const videoChannel = res.locals.videoChannel |
85 | const nsfw = buildNSFWFilter(res, req.query.nsfw) | 83 | const nsfw = buildNSFWFilter(res, req.query.nsfw) |
86 | 84 | ||
87 | let name: string | 85 | let name: string |
@@ -124,7 +122,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response, n | |||
124 | feed.addItem({ | 122 | feed.addItem({ |
125 | title: video.name, | 123 | title: video.name, |
126 | id: video.url, | 124 | id: video.url, |
127 | link: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid, | 125 | link: WEBSERVER.URL + '/videos/watch/' + video.uuid, |
128 | description: video.getTruncatedDescription(), | 126 | description: video.getTruncatedDescription(), |
129 | content: video.description, | 127 | content: video.description, |
130 | author: [ | 128 | author: [ |
@@ -139,7 +137,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response, n | |||
139 | torrent: torrents, | 137 | torrent: torrents, |
140 | thumbnail: [ | 138 | thumbnail: [ |
141 | { | 139 | { |
142 | url: CONFIG.WEBSERVER.URL + video.getThumbnailStaticPath(), | 140 | url: WEBSERVER.URL + video.getMiniatureStaticPath(), |
143 | height: THUMBNAILS_SIZE.height, | 141 | height: THUMBNAILS_SIZE.height, |
144 | width: THUMBNAILS_SIZE.width | 142 | width: THUMBNAILS_SIZE.width |
145 | } | 143 | } |
@@ -152,7 +150,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response, n | |||
152 | } | 150 | } |
153 | 151 | ||
154 | function initFeed (name: string, description: string) { | 152 | function initFeed (name: string, description: string) { |
155 | const webserverUrl = CONFIG.WEBSERVER.URL | 153 | const webserverUrl = WEBSERVER.URL |
156 | 154 | ||
157 | return new Feed({ | 155 | return new Feed({ |
158 | title: name, | 156 | title: name, |