-import * as express from 'express'
-import * as Feed from 'pfeed'
-import { VideoFilter } from '../../shared/models/videos/video-query.type'
+import express from 'express'
+import Feed from 'pfeed'
+import { getServerActor } from '@server/models/application/application'
+import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils'
+import { VideoInclude } from '@shared/models'
import { buildNSFWFilter } from '../helpers/express-utils'
import { CONFIG } from '../initializers/config'
import { FEEDS, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
videosSortValidator,
videoSubscriptionFeedsValidator
} from '../middlewares'
-import { cacheRoute } from '../middlewares/cache'
+import { cacheRouteFactory } from '../middlewares/cache/cache'
import { VideoModel } from '../models/video/video'
import { VideoCommentModel } from '../models/video/video-comment'
const feedsRouter = express.Router()
+const cacheRoute = cacheRouteFactory({
+ headerBlacklist: [ 'Content-Type' ]
+})
+
feedsRouter.get('/feeds/video-comments.:format',
feedsFormatValidator,
setFeedFormatContentType,
- asyncMiddleware(cacheRoute({
- headerBlacklist: [
- 'Content-Type'
- ]
- })(ROUTE_CACHE_LIFETIME.FEEDS)),
+ cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS),
asyncMiddleware(videoFeedsValidator),
asyncMiddleware(videoCommentsFeedsValidator),
asyncMiddleware(generateVideoCommentsFeed)
setDefaultVideosSort,
feedsFormatValidator,
setFeedFormatContentType,
- asyncMiddleware(cacheRoute({
- headerBlacklist: [
- 'Content-Type'
- ]
- })(ROUTE_CACHE_LIFETIME.FEEDS)),
+ cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS),
commonVideosFiltersValidator,
asyncMiddleware(videoFeedsValidator),
asyncMiddleware(generateVideoFeed)
setDefaultVideosSort,
feedsFormatValidator,
setFeedFormatContentType,
- asyncMiddleware(cacheRoute({
- headerBlacklist: [
- 'Content-Type'
- ]
- })(ROUTE_CACHE_LIFETIME.FEEDS)),
+ cacheRoute(ROUTE_CACHE_LIFETIME.FEEDS),
commonVideosFiltersValidator,
asyncMiddleware(videoSubscriptionFeedsValidator),
asyncMiddleware(generateVideoFeedForSubscriptions)
videoChannelId: videoChannel ? videoChannel.id : null
}
- const resultList = await VideoModel.listForApi({
+ const server = await getServerActor()
+ const { data } = await VideoModel.listForApi({
start,
count: FEEDS.COUNT,
sort: req.query.sort,
- includeLocalVideos: true,
+ displayOnlyForFollower: {
+ actorId: server.id,
+ orLocalVideos: true
+ },
nsfw,
- filter: req.query.filter as VideoFilter,
- withFiles: true,
+ isLocal: req.query.isLocal,
+ include: req.query.include | VideoInclude.FILES,
+ hasFiles: 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)
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,
- followerActorId: res.locals.user.Account.Actor.id,
+ isLocal: req.query.isLocal,
+
+ hasFiles: true,
+ include: req.query.include | VideoInclude.FILES,
+
+ countVideos: false,
+
+ displayOnlyForFollower: {
+ actorId: res.locals.user.Account.Actor.id,
+ orLocalVideos: false
+ },
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)
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 + video.getWatchStaticPath(),
description: video.getTruncatedDescription(),
content: video.description,
author: [