aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-27 14:44:51 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:53 +0100
commit4e50b6a1c9a3eb261e04ede73241648e6edf21d6 (patch)
treee1c6c121d561ffc1cf2996daec03a1e7f27f0a25 /server/helpers/custom-validators/videos.ts
parent74bb2cb8348d6794ed3a0e2ec94c8c9abdde82cf (diff)
downloadPeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.gz
PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.zst
PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.zip
Add shares forward and collection on videos/video channels
Diffstat (limited to 'server/helpers/custom-validators/videos.ts')
-rw-r--r--server/helpers/custom-validators/videos.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 205d8c62f..276354626 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -130,6 +130,27 @@ function checkVideoExists (id: string, res: Response, callback: () => void) {
130 }) 130 })
131} 131}
132 132
133async function isVideoExistsPromise (id: string, res: Response) {
134 let video: VideoInstance
135
136 if (validator.isInt(id)) {
137 video = await db.Video.loadAndPopulateAccountAndServerAndTags(+id)
138 } else { // UUID
139 video = await db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(id)
140 }
141
142 if (!video) {
143 res.status(404)
144 .json({ error: 'Video not found' })
145 .end()
146
147 return false
148 }
149
150 res.locals.video = video
151 return true
152}
153
133// --------------------------------------------------------------------------- 154// ---------------------------------------------------------------------------
134 155
135export { 156export {
@@ -152,5 +173,6 @@ export {
152 isVideoPrivacyValid, 173 isVideoPrivacyValid,
153 isVideoFileResolutionValid, 174 isVideoFileResolutionValid,
154 isVideoFileSizeValid, 175 isVideoFileSizeValid,
155 checkVideoExists 176 checkVideoExists,
177 isVideoExistsPromise
156} 178}