diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/videos/video-channels.ts | 5 | ||||
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 6 |
2 files changed, 5 insertions, 6 deletions
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts index a0df03f7e..d21274527 100644 --- a/server/middlewares/validators/videos/video-channels.ts +++ b/server/middlewares/validators/videos/video-channels.ts | |||
@@ -13,8 +13,7 @@ import { isActorPreferredUsernameValid } from '../../../helpers/custom-validator | |||
13 | import { ActorModel } from '../../../models/activitypub/actor' | 13 | import { ActorModel } from '../../../models/activitypub/actor' |
14 | import { isBooleanValid } from '../../../helpers/custom-validators/misc' | 14 | import { isBooleanValid } from '../../../helpers/custom-validators/misc' |
15 | import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares' | 15 | import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares' |
16 | import { MChannelActorAccountDefault } from '../../../typings/models/video' | 16 | import { MChannelAccountDefault, MUser } from '@server/typings/models' |
17 | import { MUser } from '@server/typings/models' | ||
18 | 17 | ||
19 | const videoChannelsAddValidator = [ | 18 | const videoChannelsAddValidator = [ |
20 | body('name').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'), | 19 | body('name').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'), |
@@ -132,7 +131,7 @@ export { | |||
132 | 131 | ||
133 | // --------------------------------------------------------------------------- | 132 | // --------------------------------------------------------------------------- |
134 | 133 | ||
135 | function checkUserCanDeleteVideoChannel (user: MUser, videoChannel: MChannelActorAccountDefault, res: express.Response) { | 134 | function checkUserCanDeleteVideoChannel (user: MUser, videoChannel: MChannelAccountDefault, res: express.Response) { |
136 | if (videoChannel.Actor.isOwned() === false) { | 135 | if (videoChannel.Actor.isOwned() === false) { |
137 | res.status(403) | 136 | res.status(403) |
138 | .json({ error: 'Cannot remove video channel of another server.' }) | 137 | .json({ error: 'Cannot remove video channel of another server.' }) |
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index a194d14b3..1449903b7 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -44,7 +44,7 @@ import { isLocalVideoAccepted } from '../../../lib/moderation' | |||
44 | import { Hooks } from '../../../lib/plugins/hooks' | 44 | import { Hooks } from '../../../lib/plugins/hooks' |
45 | import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../../../helpers/middlewares' | 45 | import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../../../helpers/middlewares' |
46 | import { MVideoFullLight } from '@server/typings/models' | 46 | import { MVideoFullLight } from '@server/typings/models' |
47 | import { getVideo } from '../../../helpers/video' | 47 | import { getVideoWithAttributes } from '../../../helpers/video' |
48 | 48 | ||
49 | const videosAddValidator = getCommonVideoEditAttributes().concat([ | 49 | const videosAddValidator = getCommonVideoEditAttributes().concat([ |
50 | body('videofile') | 50 | body('videofile') |
@@ -123,7 +123,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([ | |||
123 | ]) | 123 | ]) |
124 | 124 | ||
125 | async function checkVideoFollowConstraints (req: express.Request, res: express.Response, next: express.NextFunction) { | 125 | async function checkVideoFollowConstraints (req: express.Request, res: express.Response, next: express.NextFunction) { |
126 | const video = getVideo(res) | 126 | const video = getVideoWithAttributes(res) |
127 | 127 | ||
128 | // Anybody can watch local videos | 128 | // Anybody can watch local videos |
129 | if (video.isOwned() === true) return next() | 129 | if (video.isOwned() === true) return next() |
@@ -157,7 +157,7 @@ const videosCustomGetValidator = (fetchType: 'all' | 'only-video' | 'only-video- | |||
157 | if (areValidationErrors(req, res)) return | 157 | if (areValidationErrors(req, res)) return |
158 | if (!await doesVideoExist(req.params.id, res, fetchType)) return | 158 | if (!await doesVideoExist(req.params.id, res, fetchType)) return |
159 | 159 | ||
160 | const video = getVideo(res) | 160 | const video = getVideoWithAttributes(res) |
161 | const videoAll = video as MVideoFullLight | 161 | const videoAll = video as MVideoFullLight |
162 | 162 | ||
163 | // Video private or blacklisted | 163 | // Video private or blacklisted |