import { values } from 'lodash'
import 'multer'
import * as validator from 'validator'
-import { UserRight, VideoPrivacy, VideoRateType } from '../../../shared'
+import { UserRight, VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
import {
CONSTRAINTS_FIELDS,
VIDEO_CATEGORIES,
const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
+function isVideoFilterValid (filter: VideoFilter) {
+ return filter === 'local' || filter === 'all-local'
+}
+
function isVideoCategoryValid (value: any) {
return value === null || VIDEO_CATEGORIES[ value ] !== undefined
}
}
async function isVideoExist (id: string, res: Response, fetchType: VideoFetchType = 'all') {
- const video = await fetchVideo(id, fetchType)
+ const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined
+
+ const video = await fetchVideo(id, fetchType, userId)
if (video === null) {
res.status(404)
isVideoExist,
isVideoImage,
isVideoChannelOfAccountExist,
- isVideoSupportValid
+ isVideoSupportValid,
+ isVideoFilterValid
}