aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/video-channels.ts')
-rw-r--r--server/middlewares/validators/video-channels.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts
index 7d611728b..53416a857 100644
--- a/server/middlewares/validators/video-channels.ts
+++ b/server/middlewares/validators/video-channels.ts
@@ -9,19 +9,19 @@ import {
9 isVideoChannelDescriptionValid, 9 isVideoChannelDescriptionValid,
10 isVideoChannelNameValid, 10 isVideoChannelNameValid,
11 checkVideoChannelExists, 11 checkVideoChannelExists,
12 checkVideoAuthorExists 12 checkVideoAccountExists
13} from '../../helpers' 13} from '../../helpers'
14import { UserInstance } from '../../models' 14import { UserInstance } from '../../models'
15import { UserRight } from '../../../shared' 15import { UserRight } from '../../../shared'
16 16
17const listVideoAuthorChannelsValidator = [ 17const listVideoAccountChannelsValidator = [
18 param('authorId').custom(isIdOrUUIDValid).withMessage('Should have a valid author id'), 18 param('accountId').custom(isIdOrUUIDValid).withMessage('Should have a valid account id'),
19 19
20 (req: express.Request, res: express.Response, next: express.NextFunction) => { 20 (req: express.Request, res: express.Response, next: express.NextFunction) => {
21 logger.debug('Checking listVideoAuthorChannelsValidator parameters', { parameters: req.body }) 21 logger.debug('Checking listVideoAccountChannelsValidator parameters', { parameters: req.body })
22 22
23 checkErrors(req, res, () => { 23 checkErrors(req, res, () => {
24 checkVideoAuthorExists(req.params.authorId, res, next) 24 checkVideoAccountExists(req.params.accountId, res, next)
25 }) 25 })
26 } 26 }
27] 27]
@@ -54,7 +54,7 @@ const videoChannelsUpdateValidator = [
54 .end() 54 .end()
55 } 55 }
56 56
57 if (res.locals.videoChannel.Author.userId !== res.locals.oauth.token.User.id) { 57 if (res.locals.videoChannel.Account.userId !== res.locals.oauth.token.User.id) {
58 return res.status(403) 58 return res.status(403)
59 .json({ error: 'Cannot update video channel of another user' }) 59 .json({ error: 'Cannot update video channel of another user' })
60 .end() 60 .end()
@@ -98,7 +98,7 @@ const videoChannelGetValidator = [
98// --------------------------------------------------------------------------- 98// ---------------------------------------------------------------------------
99 99
100export { 100export {
101 listVideoAuthorChannelsValidator, 101 listVideoAccountChannelsValidator,
102 videoChannelsAddValidator, 102 videoChannelsAddValidator,
103 videoChannelsUpdateValidator, 103 videoChannelsUpdateValidator,
104 videoChannelsRemoveValidator, 104 videoChannelsRemoveValidator,
@@ -119,8 +119,8 @@ function checkUserCanDeleteVideoChannel (res: express.Response, callback: () =>
119 119
120 // Check if the user can delete the video channel 120 // Check if the user can delete the video channel
121 // The user can delete it if s/he is an admin 121 // The user can delete it if s/he is an admin
122 // Or if s/he is the video channel's author 122 // Or if s/he is the video channel's account
123 if (user.hasRight(UserRight.REMOVE_ANY_VIDEO_CHANNEL) === false && res.locals.videoChannel.Author.userId !== user.id) { 123 if (user.hasRight(UserRight.REMOVE_ANY_VIDEO_CHANNEL) === false && res.locals.videoChannel.Account.userId !== user.id) {
124 return res.status(403) 124 return res.status(403)
125 .json({ error: 'Cannot remove video channel of another user' }) 125 .json({ error: 'Cannot remove video channel of another user' })
126 .end() 126 .end()
@@ -131,7 +131,7 @@ function checkUserCanDeleteVideoChannel (res: express.Response, callback: () =>
131} 131}
132 132
133function checkVideoChannelIsNotTheLastOne (res: express.Response, callback: () => void) { 133function checkVideoChannelIsNotTheLastOne (res: express.Response, callback: () => void) {
134 db.VideoChannel.countByAuthor(res.locals.oauth.token.User.Author.id) 134 db.VideoChannel.countByAccount(res.locals.oauth.token.User.Account.id)
135 .then(count => { 135 .then(count => {
136 if (count <= 1) { 136 if (count <= 1) {
137 return res.status(409) 137 return res.status(409)