-async function generateFeed (req: express.Request, res: express.Response, next: express.NextFunction) {
- let feed = initFeed()
- const paginationStart = 0
- const paginationCount = 20
-
- let resultList: ResultList<VideoModel>
- const account: AccountModel = res.locals.account
-
- if (account) {
- resultList = await VideoModel.listAccountVideosForApi(
- account.id,
- paginationStart,
- paginationCount,
- req.query.sort,
- true
- )
+async function generateVideoCommentsFeed (req: express.Request, res: express.Response) {
+ const start = 0
+
+ const video = res.locals.video
+ const videoId: number = video ? video.id : undefined
+
+ const comments = await VideoCommentModel.listForFeed(start, FEEDS.COUNT, videoId)
+
+ const name = video ? video.name : CONFIG.INSTANCE.NAME
+ const description = video ? video.description : CONFIG.INSTANCE.DESCRIPTION
+ const feed = initFeed(name, description)
+
+ // Adding video items to the feed, one at a time
+ comments.forEach(comment => {
+ const link = WEBSERVER.URL + comment.getCommentStaticPath()
+
+ feed.addItem({
+ title: `${comment.Video.name} - ${comment.Account.getDisplayName()}`,
+ id: comment.url,
+ link,
+ content: comment.text,
+ author: [
+ {
+ name: comment.Account.getDisplayName(),
+ link: comment.Account.Actor.url
+ }
+ ],
+ date: comment.createdAt
+ })
+ })
+
+ // Now the feed generation is done, let's send it!
+ return sendFeed(feed, req, res)
+}
+
+async function generateVideoFeed (req: express.Request, res: express.Response) {
+ const start = 0
+
+ const account = res.locals.account
+ const videoChannel = res.locals.videoChannel
+ const nsfw = buildNSFWFilter(res, req.query.nsfw)
+
+ let name: string
+ let description: string
+
+ if (videoChannel) {
+ name = videoChannel.getDisplayName()
+ description = videoChannel.description
+ } else if (account) {
+ name = account.getDisplayName()
+ description = account.description