aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-11 15:10:13 +0200
committerChocobozzz <me@florianbigard.com>2018-05-11 15:25:51 +0200
commit0f320037e689b2778959c12ddd4ce790f6e4ae4f (patch)
tree425acaa4345442388901c833275bb76b42a8a268 /server/helpers/custom-validators
parent9675333decd0b89b73a4fc67b39272f7296bfe3f (diff)
downloadPeerTube-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.ts16
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'
15import { VideoModel } from '../../models/video/video' 15import { VideoModel } from '../../models/video/video'
16import { exists, isArray, isFileValid } from './misc' 16import { exists, isArray, isFileValid } from './misc'
17import { VideoChannelModel } from '../../models/video/video-channel'
17 18
18const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS 19const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
19const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES 20const 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
128async 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
129export { 144export {
@@ -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}