aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/feeds.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/feeds.ts')
-rw-r--r--server/controllers/feeds.ts25
1 files changed, 17 insertions, 8 deletions
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts
index fa6c7ac71..72628dffb 100644
--- a/server/controllers/feeds.ts
+++ b/server/controllers/feeds.ts
@@ -6,7 +6,9 @@ import {
6 setDefaultSort, 6 setDefaultSort,
7 videoCommentsFeedsValidator, 7 videoCommentsFeedsValidator,
8 videoFeedsValidator, 8 videoFeedsValidator,
9 videosSortValidator 9 videosSortValidator,
10 feedsFormatValidator,
11 setFeedFormatContentType
10} from '../middlewares' 12} from '../middlewares'
11import { VideoModel } from '../models/video/video' 13import { VideoModel } from '../models/video/video'
12import * as Feed from 'pfeed' 14import * as Feed from 'pfeed'
@@ -18,7 +20,13 @@ import { CONFIG } from '../initializers/config'
18const feedsRouter = express.Router() 20const feedsRouter = express.Router()
19 21
20feedsRouter.get('/feeds/video-comments.:format', 22feedsRouter.get('/feeds/video-comments.:format',
21 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS)), 23 feedsFormatValidator,
24 setFeedFormatContentType,
25 asyncMiddleware(cacheRoute({
26 headerBlacklist: [
27 'Content-Type'
28 ]
29 })(ROUTE_CACHE_LIFETIME.FEEDS)),
22 asyncMiddleware(videoCommentsFeedsValidator), 30 asyncMiddleware(videoCommentsFeedsValidator),
23 asyncMiddleware(generateVideoCommentsFeed) 31 asyncMiddleware(generateVideoCommentsFeed)
24) 32)
@@ -26,7 +34,13 @@ feedsRouter.get('/feeds/video-comments.:format',
26feedsRouter.get('/feeds/videos.:format', 34feedsRouter.get('/feeds/videos.:format',
27 videosSortValidator, 35 videosSortValidator,
28 setDefaultSort, 36 setDefaultSort,
29 asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS)), 37 feedsFormatValidator,
38 setFeedFormatContentType,
39 asyncMiddleware(cacheRoute({
40 headerBlacklist: [
41 'Content-Type'
42 ]
43 })(ROUTE_CACHE_LIFETIME.FEEDS)),
30 commonVideosFiltersValidator, 44 commonVideosFiltersValidator,
31 asyncMiddleware(videoFeedsValidator), 45 asyncMiddleware(videoFeedsValidator),
32 asyncMiddleware(generateVideoFeed) 46 asyncMiddleware(generateVideoFeed)
@@ -224,26 +238,21 @@ function sendFeed (feed, req: express.Request, res: express.Response) {
224 const format = req.params.format 238 const format = req.params.format
225 239
226 if (format === 'atom' || format === 'atom1') { 240 if (format === 'atom' || format === 'atom1') {
227 res.set('Content-Type', 'application/atom+xml')
228 return res.send(feed.atom1()).end() 241 return res.send(feed.atom1()).end()
229 } 242 }
230 243
231 if (format === 'json' || format === 'json1') { 244 if (format === 'json' || format === 'json1') {
232 res.set('Content-Type', 'application/json')
233 return res.send(feed.json1()).end() 245 return res.send(feed.json1()).end()
234 } 246 }
235 247
236 if (format === 'rss' || format === 'rss2') { 248 if (format === 'rss' || format === 'rss2') {
237 res.set('Content-Type', 'application/rss+xml')
238 return res.send(feed.rss2()).end() 249 return res.send(feed.rss2()).end()
239 } 250 }
240 251
241 // We're in the ambiguous '.xml' case and we look at the format query parameter 252 // We're in the ambiguous '.xml' case and we look at the format query parameter
242 if (req.query.format === 'atom' || req.query.format === 'atom1') { 253 if (req.query.format === 'atom' || req.query.format === 'atom1') {
243 res.set('Content-Type', 'application/atom+xml')
244 return res.send(feed.atom1()).end() 254 return res.send(feed.atom1()).end()
245 } 255 }
246 256
247 res.set('Content-Type', 'application/rss+xml')
248 return res.send(feed.rss2()).end() 257 return res.send(feed.rss2()).end()
249} 258}