diff options
-rw-r--r-- | server/controllers/feeds.ts | 7 | ||||
-rw-r--r-- | server/middlewares/validators/feeds.ts | 10 |
2 files changed, 8 insertions, 9 deletions
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index 7dcaf7004..08f179509 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts | |||
@@ -3,10 +3,9 @@ import { CONFIG, FEEDS } from '../initializers/constants' | |||
3 | import { asyncMiddleware, feedsValidator, setDefaultSort, videosSortValidator } from '../middlewares' | 3 | import { asyncMiddleware, feedsValidator, setDefaultSort, videosSortValidator } from '../middlewares' |
4 | import { VideoModel } from '../models/video/video' | 4 | import { VideoModel } from '../models/video/video' |
5 | import * as Feed from 'pfeed' | 5 | import * as Feed from 'pfeed' |
6 | import { ResultList } from '../../shared/models' | ||
7 | import { AccountModel } from '../models/account/account' | 6 | import { AccountModel } from '../models/account/account' |
8 | import { cacheRoute } from '../middlewares/cache' | 7 | import { cacheRoute } from '../middlewares/cache' |
9 | import { VideoSortField } from '../../client/src/app/shared/video/sort-field.type' | 8 | import { VideoChannelModel } from '../models/video/video-channel' |
10 | 9 | ||
11 | const feedsRouter = express.Router() | 10 | const feedsRouter = express.Router() |
12 | 11 | ||
@@ -31,6 +30,7 @@ async function generateFeed (req: express.Request, res: express.Response, next: | |||
31 | const start = 0 | 30 | const start = 0 |
32 | 31 | ||
33 | const account: AccountModel = res.locals.account | 32 | const account: AccountModel = res.locals.account |
33 | const videoChannel: VideoChannelModel = res.locals.videoChannel | ||
34 | const hideNSFW = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY === 'do_not_list' | 34 | const hideNSFW = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY === 'do_not_list' |
35 | 35 | ||
36 | const resultList = await VideoModel.listForApi({ | 36 | const resultList = await VideoModel.listForApi({ |
@@ -40,7 +40,8 @@ async function generateFeed (req: express.Request, res: express.Response, next: | |||
40 | hideNSFW, | 40 | hideNSFW, |
41 | filter: req.query.filter, | 41 | filter: req.query.filter, |
42 | withFiles: true, | 42 | withFiles: true, |
43 | accountId: account ? account.id : null | 43 | accountId: account ? account.id : null, |
44 | videoChannelId: videoChannel ? videoChannel.id : null | ||
44 | }) | 45 | }) |
45 | 46 | ||
46 | // Adding video items to the feed, one at a time | 47 | // Adding video items to the feed, one at a time |
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts index 6a8cfce86..b55190559 100644 --- a/server/middlewares/validators/feeds.ts +++ b/server/middlewares/validators/feeds.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param, query } from 'express-validator/check' | 2 | import { param, query } from 'express-validator/check' |
3 | import { isAccountIdExist, isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts' | 3 | import { isAccountIdExist, isAccountNameValid } from '../../helpers/custom-validators/accounts' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | 5 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
7 | import { areValidationErrors } from './utils' | 7 | import { areValidationErrors } from './utils' |
8 | import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' | 8 | import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' |
9 | import { isVideoChannelExist } from '../../helpers/custom-validators/video-channels' | ||
9 | 10 | ||
10 | const feedsValidator = [ | 11 | const feedsValidator = [ |
11 | param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), | 12 | param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), |
@@ -18,11 +19,8 @@ const feedsValidator = [ | |||
18 | 19 | ||
19 | if (areValidationErrors(req, res)) return | 20 | if (areValidationErrors(req, res)) return |
20 | 21 | ||
21 | if (req.query.accountId) { | 22 | if (req.query.accountId && !await isAccountIdExist(req.query.accountId, res)) return |
22 | if (!await isAccountIdExist(req.query.accountId, res)) return | 23 | if (req.query.videoChannelId && !await isVideoChannelExist(req.query.videoChannelId, res)) return |
23 | } else if (req.query.accountName) { | ||
24 | if (!await isLocalAccountNameExist(req.query.accountName, res)) return | ||
25 | } | ||
26 | 24 | ||
27 | return next() | 25 | return next() |
28 | } | 26 | } |