X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideos.ts;h=214db17a125714cf2cddc6325158272ce5821f53;hb=f023a19c3eeeea2b014b47fae522a62eab320048;hp=ce4492a30602f36e2bf7473961118fb148b48073;hpb=1e74f19a2179df7fc2e0da73163ef2c3118cbecb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index ce4492a30..214db17a1 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -5,13 +5,14 @@ import 'multer' import * as validator from 'validator' import { UserRight, VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared' import { - CONSTRAINTS_FIELDS, MIMETYPES, + CONSTRAINTS_FIELDS, + MIMETYPES, VIDEO_CATEGORIES, VIDEO_LICENCES, VIDEO_PRIVACIES, VIDEO_RATE_TYPES, VIDEO_STATES -} from '../../initializers' +} from '../../initializers/constants' import { VideoModel } from '../../models/video/video' import { exists, isArray, isDateValid, isFileValid } from './misc' import { VideoChannelModel } from '../../models/video/video-channel' @@ -88,8 +89,8 @@ function isVideoFileExtnameValid (value: string) { function isVideoFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[]) { const videoFileTypesRegex = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT) - .map(m => `(${m})`) - .join('|') + .map(m => `(${m})`) + .join('|') return isFileValid(files, videoFileTypesRegex, 'videofile', null) } @@ -165,7 +166,7 @@ function checkUserCanManageVideo (user: UserModel, video: VideoModel, right: Use return true } -async function isVideoExist (id: string, res: Response, fetchType: VideoFetchType = 'all') { +async function doesVideoExist (id: number | string, res: Response, fetchType: VideoFetchType = 'all') { const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined const video = await fetchVideo(id, fetchType, userId) @@ -182,7 +183,7 @@ async function isVideoExist (id: string, res: Response, fetchType: VideoFetchTyp return true } -async function isVideoChannelOfAccountExist (channelId: number, user: UserModel, res: Response) { +async function doesVideoChannelOfAccountExist (channelId: number, user: UserModel, res: Response) { if (user.hasRight(UserRight.UPDATE_ANY_VIDEO) === true) { const videoChannel = await VideoChannelModel.loadAndPopulateAccount(channelId) if (videoChannel === null) { @@ -236,9 +237,9 @@ export { isVideoPrivacyValid, isVideoFileResolutionValid, isVideoFileSizeValid, - isVideoExist, + doesVideoExist, isVideoImage, - isVideoChannelOfAccountExist, + doesVideoChannelOfAccountExist, isVideoSupportValid, isVideoFilterValid }