diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-11 15:10:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-11 15:25:51 +0200 |
commit | 0f320037e689b2778959c12ddd4ce790f6e4ae4f (patch) | |
tree | 425acaa4345442388901c833275bb76b42a8a268 /server/helpers/custom-validators | |
parent | 9675333decd0b89b73a4fc67b39272f7296bfe3f (diff) | |
download | PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.tar.gz PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.tar.zst PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.zip |
Add ability to update a video channel
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 23d2d8ac6..c35db49ac 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -14,6 +14,7 @@ import { | |||
14 | } from '../../initializers' | 14 | } from '../../initializers' |
15 | import { VideoModel } from '../../models/video/video' | 15 | import { VideoModel } from '../../models/video/video' |
16 | import { exists, isArray, isFileValid } from './misc' | 16 | import { exists, isArray, isFileValid } from './misc' |
17 | import { VideoChannelModel } from '../../models/video/video-channel' | ||
17 | 18 | ||
18 | const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS | 19 | const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS |
19 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES | 20 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES |
@@ -124,6 +125,20 @@ async function isVideoExist (id: string, res: Response) { | |||
124 | return true | 125 | return true |
125 | } | 126 | } |
126 | 127 | ||
128 | async function isVideoChannelOfAccountExist (channelId: number, accountId: number, res: Response) { | ||
129 | const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, accountId) | ||
130 | if (!videoChannel) { | ||
131 | res.status(400) | ||
132 | .json({ error: 'Unknown video video channel for this account.' }) | ||
133 | .end() | ||
134 | |||
135 | return false | ||
136 | } | ||
137 | |||
138 | res.locals.videoChannel = videoChannel | ||
139 | return true | ||
140 | } | ||
141 | |||
127 | // --------------------------------------------------------------------------- | 142 | // --------------------------------------------------------------------------- |
128 | 143 | ||
129 | export { | 144 | export { |
@@ -146,5 +161,6 @@ export { | |||
146 | isVideoFileSizeValid, | 161 | isVideoFileSizeValid, |
147 | isVideoExist, | 162 | isVideoExist, |
148 | isVideoImage, | 163 | isVideoImage, |
164 | isVideoChannelOfAccountExist, | ||
149 | isVideoSupportValid | 165 | isVideoSupportValid |
150 | } | 166 | } |