Does exist
authorChocobozzz <me@florianbigard.com>
Tue, 19 Mar 2019 08:26:50 +0000 (09:26 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 19 Mar 2019 08:26:50 +0000 (09:26 +0100)
28 files changed:
server/controllers/api/videos/index.ts
server/helpers/custom-validators/accounts.ts
server/helpers/custom-validators/video-abuses.ts
server/helpers/custom-validators/video-blacklist.ts
server/helpers/custom-validators/video-captions.ts
server/helpers/custom-validators/video-channels.ts
server/helpers/custom-validators/video-imports.ts
server/helpers/custom-validators/video-playlists.ts
server/helpers/custom-validators/videos.ts
server/lib/redis.ts
server/middlewares/validators/account.ts
server/middlewares/validators/blocklist.ts
server/middlewares/validators/feeds.ts
server/middlewares/validators/oembed.ts
server/middlewares/validators/redundancy.ts
server/middlewares/validators/server.ts
server/middlewares/validators/users.ts
server/middlewares/validators/videos/video-abuses.ts
server/middlewares/validators/videos/video-blacklist.ts
server/middlewares/validators/videos/video-captions.ts
server/middlewares/validators/videos/video-channels.ts
server/middlewares/validators/videos/video-comments.ts
server/middlewares/validators/videos/video-imports.ts
server/middlewares/validators/videos/video-playlists.ts
server/middlewares/validators/videos/video-rates.ts
server/middlewares/validators/videos/video-shares.ts
server/middlewares/validators/videos/video-watch.ts
server/middlewares/validators/videos/videos.ts

index 6ac13e6a4401ad996c25ff0b19b09844a67e57a4..27f67895e6db83dcf521fb969a41362a43ede6fe 100644 (file)
@@ -421,7 +421,7 @@ async function viewVideo (req: express.Request, res: express.Response) {
   const videoInstance = res.locals.video
 
   const ip = req.ip
-  const exists = await Redis.Instance.isVideoIPViewExists(ip, videoInstance.uuid)
+  const exists = await Redis.Instance.doesVideoIPViewExist(ip, videoInstance.uuid)
   if (exists) {
     logger.debug('View for ip %s and video %s already exists.', ip, videoInstance.uuid)
     return res.status(204).end()
index aad04fe934ec2fd511cc45086b5cadee4b001959..146c7708e2168967430cf9ffb6dd746985849a8c 100644 (file)
@@ -5,7 +5,6 @@ import * as validator from 'validator'
 import { AccountModel } from '../../models/account/account'
 import { isUserDescriptionValid, isUserUsernameValid } from './users'
 import { exists } from './misc'
-import { CONFIG } from '../../initializers'
 
 function isAccountNameValid (value: string) {
   return isUserUsernameValid(value)
@@ -19,7 +18,7 @@ function isAccountDescriptionValid (value: string) {
   return isUserDescriptionValid(value)
 }
 
-function isAccountIdExist (id: number | string, res: Response, sendNotFound = true) {
+function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) {
   let promise: Bluebird<AccountModel>
 
   if (validator.isInt('' + id)) {
@@ -28,20 +27,20 @@ function isAccountIdExist (id: number | string, res: Response, sendNotFound = tr
     promise = AccountModel.loadByUUID('' + id)
   }
 
-  return isAccountExist(promise, res, sendNotFound)
+  return doesAccountExist(promise, res, sendNotFound)
 }
 
-function isLocalAccountNameExist (name: string, res: Response, sendNotFound = true) {
+function doesLocalAccountNameExist (name: string, res: Response, sendNotFound = true) {
   const promise = AccountModel.loadLocalByName(name)
 
-  return isAccountExist(promise, res, sendNotFound)
+  return doesAccountExist(promise, res, sendNotFound)
 }
 
-function isAccountNameWithHostExist (nameWithDomain: string, res: Response, sendNotFound = true) {
-  return isAccountExist(AccountModel.loadByNameWithHost(nameWithDomain), res, sendNotFound)
+function doesAccountNameWithHostExist (nameWithDomain: string, res: Response, sendNotFound = true) {
+  return doesAccountExist(AccountModel.loadByNameWithHost(nameWithDomain), res, sendNotFound)
 }
 
-async function isAccountExist (p: Bluebird<AccountModel>, res: Response, sendNotFound: boolean) {
+async function doesAccountExist (p: Bluebird<AccountModel>, res: Response, sendNotFound: boolean) {
   const account = await p
 
   if (!account) {
@@ -63,9 +62,9 @@ async function isAccountExist (p: Bluebird<AccountModel>, res: Response, sendNot
 
 export {
   isAccountIdValid,
-  isAccountIdExist,
-  isLocalAccountNameExist,
+  doesAccountIdExist,
+  doesLocalAccountNameExist,
   isAccountDescriptionValid,
-  isAccountNameWithHostExist,
+  doesAccountNameWithHostExist,
   isAccountNameValid
 }
index 290efb14970e0d8272fc16456c095f705b5e3b7b..71500fde5b91a29f100be304a32eedfd18325043 100644 (file)
@@ -18,7 +18,7 @@ function isVideoAbuseStateValid (value: string) {
   return exists(value) && VIDEO_ABUSE_STATES[ value ] !== undefined
 }
 
-async function isVideoAbuseExist (abuseId: number, videoId: number, res: Response) {
+async function doesVideoAbuseExist (abuseId: number, videoId: number, res: Response) {
   const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId)
 
   if (videoAbuse === null) {
@@ -36,7 +36,7 @@ async function isVideoAbuseExist (abuseId: number, videoId: number, res: Respons
 // ---------------------------------------------------------------------------
 
 export {
-  isVideoAbuseExist,
+  doesVideoAbuseExist,
   isVideoAbuseStateValid,
   isVideoAbuseReasonValid,
   isVideoAbuseModerationCommentValid
index b36b08d8bd275672481b1dee60349949f08e0044..25f90822847fda52028ece9d19b498b4f9a66493 100644 (file)
@@ -9,7 +9,7 @@ function isVideoBlacklistReasonValid (value: string) {
   return value === null || validator.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON)
 }
 
-async function isVideoBlacklistExist (videoId: number, res: Response) {
+async function doesVideoBlacklistExist (videoId: number, res: Response) {
   const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId)
 
   if (videoBlacklist === null) {
@@ -28,5 +28,5 @@ async function isVideoBlacklistExist (videoId: number, res: Response) {
 
 export {
   isVideoBlacklistReasonValid,
-  isVideoBlacklistExist
+  doesVideoBlacklistExist
 }
index b33d90e1856f5bc3a77683f2c8d321ec4b763dfa..8bd1390030bab4802697bf867da7f7260bc065c2 100644 (file)
@@ -16,7 +16,7 @@ function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File
   return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max)
 }
 
-async function isVideoCaptionExist (video: VideoModel, language: string, res: Response) {
+async function doesVideoCaptionExist (video: VideoModel, language: string, res: Response) {
   const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
 
   if (!videoCaption) {
@@ -36,5 +36,5 @@ async function isVideoCaptionExist (video: VideoModel, language: string, res: Re
 export {
   isVideoCaptionFile,
   isVideoCaptionLanguageValid,
-  isVideoCaptionExist
+  doesVideoCaptionExist
 }
index 3792bbdcc8290a738a5d5ddc08a6f0c82b2c73ec..fad7a9bcf38907a20bdda900c5c82a3c39aded70 100644 (file)
@@ -20,13 +20,13 @@ function isVideoChannelSupportValid (value: string) {
   return value === null || (exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT))
 }
 
-async function isLocalVideoChannelNameExist (name: string, res: express.Response) {
+async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
   const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
 
   return processVideoChannelExist(videoChannel, res)
 }
 
-async function isVideoChannelIdExist (id: number | string, res: express.Response) {
+async function doesVideoChannelIdExist (id: number | string, res: express.Response) {
   let videoChannel: VideoChannelModel
   if (validator.isInt('' + id)) {
     videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
@@ -37,7 +37,7 @@ async function isVideoChannelIdExist (id: number | string, res: express.Response
   return processVideoChannelExist(videoChannel, res)
 }
 
-async function isVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) {
+async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) {
   const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain)
 
   return processVideoChannelExist(videoChannel, res)
@@ -46,12 +46,12 @@ async function isVideoChannelNameWithHostExist (nameWithDomain: string, res: exp
 // ---------------------------------------------------------------------------
 
 export {
-  isVideoChannelNameWithHostExist,
-  isLocalVideoChannelNameExist,
+  doesVideoChannelNameWithHostExist,
+  doesLocalVideoChannelNameExist,
   isVideoChannelDescriptionValid,
   isVideoChannelNameValid,
   isVideoChannelSupportValid,
-  isVideoChannelIdExist
+  doesVideoChannelIdExist
 }
 
 function processVideoChannelExist (videoChannel: VideoChannelModel, res: express.Response) {
index ce9e9193cebf5b0d9fc977067a2ca2ed327a3919..14db9b534345ff4a577f98546c2c4c65b11d98de 100644 (file)
@@ -30,7 +30,7 @@ function isVideoImportTorrentFile (files: { [ fieldname: string ]: Express.Multe
   return isFileValid(files, videoTorrentImportRegex, 'torrentfile', CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_FILE.FILE_SIZE.max, true)
 }
 
-async function isVideoImportExist (id: number, res: express.Response) {
+async function doesVideoImportExist (id: number, res: express.Response) {
   const videoImport = await VideoImportModel.loadAndPopulateVideo(id)
 
   if (!videoImport) {
@@ -50,6 +50,6 @@ async function isVideoImportExist (id: number, res: express.Response) {
 export {
   isVideoImportStateValid,
   isVideoImportTargetUrlValid,
-  isVideoImportExist,
+  doesVideoImportExist,
   isVideoImportTorrentFile
 }
index e0eb423d7334f2dbd4ad3cb19ec166de40dd1397..c962c5532348c27f17203ed28f20b30ee0d7fa83 100644 (file)
@@ -26,7 +26,7 @@ function isVideoPlaylistTypeValid (value: any) {
   return exists(value) && VIDEO_PLAYLIST_TYPES[ value ] !== undefined
 }
 
-async function isVideoPlaylistExist (id: number | string, res: express.Response, fetchType: 'summary' | 'all' = 'summary') {
+async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: 'summary' | 'all' = 'summary') {
   const videoPlaylist = fetchType === 'summary'
     ? await VideoPlaylistModel.loadWithAccountAndChannelSummary(id, undefined)
     : await VideoPlaylistModel.loadWithAccountAndChannel(id, undefined)
@@ -46,7 +46,7 @@ async function isVideoPlaylistExist (id: number | string, res: express.Response,
 // ---------------------------------------------------------------------------
 
 export {
-  isVideoPlaylistExist,
+  doesVideoPlaylistExist,
   isVideoPlaylistNameValid,
   isVideoPlaylistDescriptionValid,
   isVideoPlaylistPrivacyValid,
index d00d24c4c9831a20ad74ca6b13c94d24e133e486..dd9d62d24192e315bc9dbb3a68aa5590895e3abc 100644 (file)
@@ -165,7 +165,7 @@ function checkUserCanManageVideo (user: UserModel, video: VideoModel, right: Use
   return true
 }
 
-async function isVideoExist (id: number | 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 +182,7 @@ async function isVideoExist (id: number | string, res: Response, fetchType: Vide
   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 +236,9 @@ export {
   isVideoPrivacyValid,
   isVideoFileResolutionValid,
   isVideoFileSizeValid,
-  isVideoExist,
+  doesVideoExist,
   isVideoImage,
-  isVideoChannelOfAccountExist,
+  doesVideoChannelOfAccountExist,
   isVideoSupportValid,
   isVideoFilterValid
 }
index 3628c0583e3006dc91f30ba60fb076285cfe5fa1..d85dbe2b5c0851b53737b138ec9d39ea93cad21e 100644 (file)
@@ -88,7 +88,7 @@ class Redis {
     return this.setValue(this.generateContactFormKey(ip), '1', CONTACT_FORM_LIFETIME)
   }
 
-  async isContactFormIpExists (ip: string) {
+  async doesContactFormIpExist (ip: string) {
     return this.exists(this.generateContactFormKey(ip))
   }
 
@@ -98,7 +98,7 @@ class Redis {
     return this.setValue(this.generateViewKey(ip, videoUUID), '1', VIDEO_VIEW_LIFETIME)
   }
 
-  async isVideoIPViewExists (ip: string, videoUUID: string) {
+  async doesVideoIPViewExist (ip: string, videoUUID: string) {
     return this.exists(this.generateViewKey(ip, videoUUID))
   }
 
index 88c57eaa1adb072830b612714b00ffebde2d3c0b..96e120a38506f9ba9a9a1289478a2a905ca71ff7 100644 (file)
@@ -1,6 +1,6 @@
 import * as express from 'express'
 import { param } from 'express-validator/check'
-import { isAccountNameValid, isAccountNameWithHostExist, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts'
+import { isAccountNameValid, doesAccountNameWithHostExist, doesLocalAccountNameExist } from '../../helpers/custom-validators/accounts'
 import { logger } from '../../helpers/logger'
 import { areValidationErrors } from './utils'
 
@@ -11,7 +11,7 @@ const localAccountValidator = [
     logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isLocalAccountNameExist(req.params.name, res)) return
+    if (!await doesLocalAccountNameExist(req.params.name, res)) return
 
     return next()
   }
@@ -24,7 +24,7 @@ const accountNameWithHostGetValidator = [
     logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isAccountNameWithHostExist(req.params.accountName, res)) return
+    if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
 
     return next()
   }
index 109276c630ce21acca5de435e3c25debfa629370..d7ec649b6ea3138abc690e3900230472c0949984 100644 (file)
@@ -2,7 +2,7 @@ import { body, param } from 'express-validator/check'
 import * as express from 'express'
 import { logger } from '../../helpers/logger'
 import { areValidationErrors } from './utils'
-import { isAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
+import { doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
 import { UserModel } from '../../models/account/user'
 import { AccountBlocklistModel } from '../../models/account/account-blocklist'
 import { isHostValid } from '../../helpers/custom-validators/servers'
@@ -18,7 +18,7 @@ const blockAccountValidator = [
     logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isAccountNameWithHostExist(req.body.accountName, res)) return
+    if (!await doesAccountNameWithHostExist(req.body.accountName, res)) return
 
     const user = res.locals.oauth.token.User as UserModel
     const accountToBlock = res.locals.account
@@ -42,11 +42,11 @@ const unblockAccountByAccountValidator = [
     logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isAccountNameWithHostExist(req.params.accountName, res)) return
+    if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
 
     const user = res.locals.oauth.token.User as UserModel
     const targetAccount = res.locals.account
-    if (!await isUnblockAccountExists(user.Account.id, targetAccount.id, res)) return
+    if (!await doesUnblockAccountExist(user.Account.id, targetAccount.id, res)) return
 
     return next()
   }
@@ -59,11 +59,11 @@ const unblockAccountByServerValidator = [
     logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isAccountNameWithHostExist(req.params.accountName, res)) return
+    if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
 
     const serverActor = await getServerActor()
     const targetAccount = res.locals.account
-    if (!await isUnblockAccountExists(serverActor.Account.id, targetAccount.id, res)) return
+    if (!await doesUnblockAccountExist(serverActor.Account.id, targetAccount.id, res)) return
 
     return next()
   }
@@ -107,7 +107,7 @@ const unblockServerByAccountValidator = [
     if (areValidationErrors(req, res)) return
 
     const user = res.locals.oauth.token.User as UserModel
-    if (!await isUnblockServerExists(user.Account.id, req.params.host, res)) return
+    if (!await doesUnblockServerExist(user.Account.id, req.params.host, res)) return
 
     return next()
   }
@@ -122,7 +122,7 @@ const unblockServerByServerValidator = [
     if (areValidationErrors(req, res)) return
 
     const serverActor = await getServerActor()
-    if (!await isUnblockServerExists(serverActor.Account.id, req.params.host, res)) return
+    if (!await doesUnblockServerExist(serverActor.Account.id, req.params.host, res)) return
 
     return next()
   }
@@ -141,7 +141,7 @@ export {
 
 // ---------------------------------------------------------------------------
 
-async function isUnblockAccountExists (accountId: number, targetAccountId: number, res: express.Response) {
+async function doesUnblockAccountExist (accountId: number, targetAccountId: number, res: express.Response) {
   const accountBlock = await AccountBlocklistModel.loadByAccountAndTarget(accountId, targetAccountId)
   if (!accountBlock) {
     res.status(404)
@@ -156,7 +156,7 @@ async function isUnblockAccountExists (accountId: number, targetAccountId: numbe
   return true
 }
 
-async function isUnblockServerExists (accountId: number, host: string, res: express.Response) {
+async function doesUnblockServerExist (accountId: number, host: string, res: express.Response) {
   const serverBlock = await ServerBlocklistModel.loadByAccountAndHost(accountId, host)
   if (!serverBlock) {
     res.status(404)
index 969ce2526ef98009c5d4a254eee2dd71b9e8a181..e4f5c98fe32a8189377fd5f742d3eae79a3d4b78 100644 (file)
@@ -1,12 +1,12 @@
 import * as express from 'express'
 import { param, query } from 'express-validator/check'
-import { isAccountIdExist, isAccountNameValid, isAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
+import { doesAccountIdExist, isAccountNameValid, doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
 import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
 import { logger } from '../../helpers/logger'
 import { areValidationErrors } from './utils'
 import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
-import { isVideoChannelIdExist, isVideoChannelNameWithHostExist } from '../../helpers/custom-validators/video-channels'
-import { isVideoExist } from '../../helpers/custom-validators/videos'
+import { doesVideoChannelIdExist, doesVideoChannelNameWithHostExist } from '../../helpers/custom-validators/video-channels'
+import { doesVideoExist } from '../../helpers/custom-validators/videos'
 import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
 
 const videoFeedsValidator = [
@@ -22,10 +22,10 @@ const videoFeedsValidator = [
 
     if (areValidationErrors(req, res)) return
 
-    if (req.query.accountId && !await isAccountIdExist(req.query.accountId, res)) return
-    if (req.query.videoChannelId && !await isVideoChannelIdExist(req.query.videoChannelId, res)) return
-    if (req.query.accountName && !await isAccountNameWithHostExist(req.query.accountName, res)) return
-    if (req.query.videoChannelName && !await isVideoChannelNameWithHostExist(req.query.videoChannelName, res)) return
+    if (req.query.accountId && !await doesAccountIdExist(req.query.accountId, res)) return
+    if (req.query.videoChannelId && !await doesVideoChannelIdExist(req.query.videoChannelId, res)) return
+    if (req.query.accountName && !await doesAccountNameWithHostExist(req.query.accountName, res)) return
+    if (req.query.videoChannelName && !await doesVideoChannelNameWithHostExist(req.query.videoChannelName, res)) return
 
     return next()
   }
@@ -41,7 +41,7 @@ const videoCommentsFeedsValidator = [
 
     if (areValidationErrors(req, res)) return
 
-    if (req.query.videoId && !await isVideoExist(req.query.videoId, res)) return
+    if (req.query.videoId && !await doesVideoExist(req.query.videoId, res)) return
 
     return next()
   }
index cd9b27b164490e7a5d5e12724e2e4e810c0e4281..c89bc26de8ae24ce2275971bdefee5bbd33f33ac 100644 (file)
@@ -3,7 +3,7 @@ import { query } from 'express-validator/check'
 import { join } from 'path'
 import { isTestInstance } from '../../helpers/core-utils'
 import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
-import { isVideoExist } from '../../helpers/custom-validators/videos'
+import { doesVideoExist } from '../../helpers/custom-validators/videos'
 import { logger } from '../../helpers/logger'
 import { CONFIG } from '../../initializers'
 import { areValidationErrors } from './utils'
@@ -52,7 +52,7 @@ const oembedValidator = [
                 .end()
     }
 
-    if (!await isVideoExist(videoId, res)) return
+    if (!await doesVideoExist(videoId, res)) return
 
     return next()
   }
index 32932250912123e7466911a830b84535cc4983c7..41992192848787a1b9daa5f78cccbeaca4b02a19 100644 (file)
@@ -2,7 +2,7 @@ import * as express from 'express'
 import 'express-validator'
 import { param, body } from 'express-validator/check'
 import { exists, isBooleanValid, isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
-import { isVideoExist } from '../../helpers/custom-validators/videos'
+import { doesVideoExist } from '../../helpers/custom-validators/videos'
 import { logger } from '../../helpers/logger'
 import { areValidationErrors } from './utils'
 import { VideoModel } from '../../models/video/video'
@@ -27,7 +27,7 @@ const videoFileRedundancyGetValidator = [
     logger.debug('Checking videoFileRedundancyGetValidator parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
 
     const video: VideoModel = res.locals.video
     const videoFile = video.VideoFiles.find(f => {
@@ -53,7 +53,7 @@ const videoPlaylistRedundancyGetValidator = [
     logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
 
     const video: VideoModel = res.locals.video
     const videoStreamingPlaylist = video.VideoStreamingPlaylists.find(p => p === req.params.streamingPlaylistType)
index d85afc2ffee8875356422d7ad5ae5ec8b0469b60..e62a17163905848a7200db29fac7e4177136fb39 100644 (file)
@@ -57,7 +57,7 @@ const contactAdministratorValidator = [
         .end()
     }
 
-    if (await Redis.Instance.isContactFormIpExists(req.ip)) {
+    if (await Redis.Instance.doesContactFormIpExist(req.ip)) {
       logger.info('Refusing a contact form by %s: already sent one recently.', req.ip)
 
       return res
index a52e3060af11514e64ee3a16b727514b3ef44420..5e8c8c29bc7fabe26d66a90f26e853da1f4f675a 100644 (file)
@@ -16,7 +16,7 @@ import {
   isUserVideoQuotaDailyValid,
   isUserVideoQuotaValid, isUserVideosHistoryEnabledValid
 } from '../../helpers/custom-validators/users'
-import { isVideoExist } from '../../helpers/custom-validators/videos'
+import { doesVideoExist } from '../../helpers/custom-validators/videos'
 import { logger } from '../../helpers/logger'
 import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
 import { Redis } from '../../lib/redis'
@@ -194,7 +194,7 @@ const usersVideoRatingValidator = [
     logger.debug('Checking usersVideoRating parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res, 'id')) return
+    if (!await doesVideoExist(req.params.videoId, res, 'id')) return
 
     return next()
   }
index be26ca16a6339aa948c6dbb3300ec178a350b0b9..d1910a992b49dcc323029b15c6a10ff38091c60c 100644 (file)
@@ -2,11 +2,11 @@ import * as express from 'express'
 import 'express-validator'
 import { body, param } from 'express-validator/check'
 import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
-import { isVideoExist } from '../../../helpers/custom-validators/videos'
+import { doesVideoExist } from '../../../helpers/custom-validators/videos'
 import { logger } from '../../../helpers/logger'
 import { areValidationErrors } from '../utils'
 import {
-  isVideoAbuseExist,
+  doesVideoAbuseExist,
   isVideoAbuseModerationCommentValid,
   isVideoAbuseReasonValid,
   isVideoAbuseStateValid
@@ -20,7 +20,7 @@ const videoAbuseReportValidator = [
     logger.debug('Checking videoAbuseReport parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
 
     return next()
   }
@@ -34,8 +34,8 @@ const videoAbuseGetValidator = [
     logger.debug('Checking videoAbuseGetValidator parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
-    if (!await isVideoAbuseExist(req.params.id, res.locals.video.id, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoAbuseExist(req.params.id, res.locals.video.id, res)) return
 
     return next()
   }
@@ -55,8 +55,8 @@ const videoAbuseUpdateValidator = [
     logger.debug('Checking videoAbuseUpdateValidator parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
-    if (!await isVideoAbuseExist(req.params.id, res.locals.video.id, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoAbuseExist(req.params.id, res.locals.video.id, res)) return
 
     return next()
   }
index 2688f63ae816e2b67632038069761fcc96b8622b..77ad29cbbd05c9ac178c453fa5ee09a7c8a42b71 100644 (file)
@@ -1,10 +1,10 @@
 import * as express from 'express'
 import { body, param } from 'express-validator/check'
 import { isBooleanValid, isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
-import { isVideoExist } from '../../../helpers/custom-validators/videos'
+import { doesVideoExist } from '../../../helpers/custom-validators/videos'
 import { logger } from '../../../helpers/logger'
 import { areValidationErrors } from '../utils'
-import { isVideoBlacklistExist, isVideoBlacklistReasonValid } from '../../../helpers/custom-validators/video-blacklist'
+import { doesVideoBlacklistExist, isVideoBlacklistReasonValid } from '../../../helpers/custom-validators/video-blacklist'
 import { VideoModel } from '../../../models/video/video'
 
 const videosBlacklistRemoveValidator = [
@@ -14,8 +14,8 @@ const videosBlacklistRemoveValidator = [
     logger.debug('Checking blacklistRemove parameters.', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
-    if (!await isVideoBlacklistExist(res.locals.video.id, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoBlacklistExist(res.locals.video.id, res)) return
 
     return next()
   }
@@ -35,7 +35,7 @@ const videosBlacklistAddValidator = [
     logger.debug('Checking videosBlacklistAdd parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
 
     const video: VideoModel = res.locals.video
     if (req.body.unfederate === true && video.remote === true) {
@@ -59,8 +59,8 @@ const videosBlacklistUpdateValidator = [
     logger.debug('Checking videosBlacklistUpdate parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
-    if (!await isVideoBlacklistExist(res.locals.video.id, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoBlacklistExist(res.locals.video.id, res)) return
 
     return next()
   }
index 63d84fbec7fc33094114029cf51d48d6e4704fba..b2b259aff4c381c50d091331a46c8a55a7a11c9c 100644 (file)
@@ -1,12 +1,12 @@
 import * as express from 'express'
 import { areValidationErrors } from '../utils'
-import { checkUserCanManageVideo, isVideoExist } from '../../../helpers/custom-validators/videos'
+import { checkUserCanManageVideo, doesVideoExist } from '../../../helpers/custom-validators/videos'
 import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
 import { body, param } from 'express-validator/check'
 import { CONSTRAINTS_FIELDS } from '../../../initializers'
 import { UserRight } from '../../../../shared'
 import { logger } from '../../../helpers/logger'
-import { isVideoCaptionExist, isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions'
+import { doesVideoCaptionExist, isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions'
 import { cleanUpReqFiles } from '../../../helpers/express-utils'
 
 const addVideoCaptionValidator = [
@@ -22,7 +22,7 @@ const addVideoCaptionValidator = [
     logger.debug('Checking addVideoCaption parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
-    if (!await isVideoExist(req.params.videoId, res)) return cleanUpReqFiles(req)
+    if (!await doesVideoExist(req.params.videoId, res)) return cleanUpReqFiles(req)
 
     // Check if the user who did the request is able to update the video
     const user = res.locals.oauth.token.User
@@ -40,8 +40,8 @@ const deleteVideoCaptionValidator = [
     logger.debug('Checking deleteVideoCaption parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
-    if (!await isVideoCaptionExist(res.locals.video, req.params.captionLanguage, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoCaptionExist(res.locals.video, req.params.captionLanguage, res)) return
 
     // Check if the user who did the request is able to update the video
     const user = res.locals.oauth.token.User
@@ -58,7 +58,7 @@ const listVideoCaptionsValidator = [
     logger.debug('Checking listVideoCaptions parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res, 'id')) return
+    if (!await doesVideoExist(req.params.videoId, res, 'id')) return
 
     return next()
   }
index c2763ce510c04b2ffe81463db29120357d9c8b75..e2067c4d99f54469420a62d2307fe04bbfa6dc5d 100644 (file)
@@ -1,12 +1,12 @@
 import * as express from 'express'
 import { body, param } from 'express-validator/check'
 import { UserRight } from '../../../../shared'
-import { isAccountNameWithHostExist } from '../../../helpers/custom-validators/accounts'
+import { doesAccountNameWithHostExist } from '../../../helpers/custom-validators/accounts'
 import {
-  isLocalVideoChannelNameExist,
+  doesLocalVideoChannelNameExist,
   isVideoChannelDescriptionValid,
   isVideoChannelNameValid,
-  isVideoChannelNameWithHostExist,
+  doesVideoChannelNameWithHostExist,
   isVideoChannelSupportValid
 } from '../../../helpers/custom-validators/video-channels'
 import { logger } from '../../../helpers/logger'
@@ -49,7 +49,7 @@ const videoChannelsUpdateValidator = [
     logger.debug('Checking videoChannelsUpdate parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
+    if (!await doesVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
 
     // We need to make additional checks
     if (res.locals.videoChannel.Actor.isOwned() === false) {
@@ -75,7 +75,7 @@ const videoChannelsRemoveValidator = [
     logger.debug('Checking videoChannelsRemove parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
+    if (!await doesVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
 
     if (!checkUserCanDeleteVideoChannel(res.locals.oauth.token.User, res.locals.videoChannel, res)) return
     if (!await checkVideoChannelIsNotTheLastOne(res)) return
@@ -92,7 +92,7 @@ const videoChannelsNameWithHostValidator = [
 
     if (areValidationErrors(req, res)) return
 
-    if (!await isVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
+    if (!await doesVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
 
     return next()
   }
@@ -105,7 +105,7 @@ const localVideoChannelValidator = [
     logger.debug('Checking localVideoChannelValidator parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isLocalVideoChannelNameExist(req.params.name, res)) return
+    if (!await doesLocalVideoChannelNameExist(req.params.name, res)) return
 
     return next()
   }
index 348d330820937f7a0e8c35d275dce2125a7d18f1..ffde208b71209aa03b1e4c03e72a82330f64570e 100644 (file)
@@ -3,7 +3,7 @@ import { body, param } from 'express-validator/check'
 import { UserRight } from '../../../../shared'
 import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
 import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments'
-import { isVideoExist } from '../../../helpers/custom-validators/videos'
+import { doesVideoExist } from '../../../helpers/custom-validators/videos'
 import { logger } from '../../../helpers/logger'
 import { UserModel } from '../../../models/account/user'
 import { VideoModel } from '../../../models/video/video'
@@ -17,7 +17,7 @@ const listVideoCommentThreadsValidator = [
     logger.debug('Checking listVideoCommentThreads parameters.', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res, 'only-video')) return
+    if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return
 
     return next()
   }
@@ -31,8 +31,8 @@ const listVideoThreadCommentsValidator = [
     logger.debug('Checking listVideoThreadComments parameters.', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res, 'only-video')) return
-    if (!await isVideoCommentThreadExist(req.params.threadId, res.locals.video, res)) return
+    if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return
+    if (!await doesVideoCommentThreadExist(req.params.threadId, res.locals.video, res)) return
 
     return next()
   }
@@ -46,7 +46,7 @@ const addVideoCommentThreadValidator = [
     logger.debug('Checking addVideoCommentThread parameters.', { parameters: req.params, body: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
     if (!isVideoCommentsEnabled(res.locals.video, res)) return
 
     return next()
@@ -62,9 +62,9 @@ const addVideoCommentReplyValidator = [
     logger.debug('Checking addVideoCommentReply parameters.', { parameters: req.params, body: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
     if (!isVideoCommentsEnabled(res.locals.video, res)) return
-    if (!await isVideoCommentExist(req.params.commentId, res.locals.video, res)) return
+    if (!await doesVideoCommentExist(req.params.commentId, res.locals.video, res)) return
 
     return next()
   }
@@ -78,8 +78,8 @@ const videoCommentGetValidator = [
     logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res, 'id')) return
-    if (!await isVideoCommentExist(req.params.commentId, res.locals.video, res)) return
+    if (!await doesVideoExist(req.params.videoId, res, 'id')) return
+    if (!await doesVideoCommentExist(req.params.commentId, res.locals.video, res)) return
 
     return next()
   }
@@ -93,8 +93,8 @@ const removeVideoCommentValidator = [
     logger.debug('Checking removeVideoCommentValidator parameters.', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
-    if (!await isVideoCommentExist(req.params.commentId, res.locals.video, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoCommentExist(req.params.commentId, res.locals.video, res)) return
 
     // Check if the user who did the request is able to delete the video
     if (!checkUserCanDeleteVideoComment(res.locals.oauth.token.User, res.locals.videoComment, res)) return
@@ -116,7 +116,7 @@ export {
 
 // ---------------------------------------------------------------------------
 
-async function isVideoCommentThreadExist (id: number, video: VideoModel, res: express.Response) {
+async function doesVideoCommentThreadExist (id: number, video: VideoModel, res: express.Response) {
   const videoComment = await VideoCommentModel.loadById(id)
 
   if (!videoComment) {
@@ -147,7 +147,7 @@ async function isVideoCommentThreadExist (id: number, video: VideoModel, res: ex
   return true
 }
 
-async function isVideoCommentExist (id: number, video: VideoModel, res: express.Response) {
+async function doesVideoCommentExist (id: number, video: VideoModel, res: express.Response) {
   const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id)
 
   if (!videoComment) {
index 121df36b67248f206d61ee49f2c0829de2a3d2c2..3d662b20f55a344503e0173035a6acd6262a15d4 100644 (file)
@@ -6,7 +6,7 @@ import { areValidationErrors } from '../utils'
 import { getCommonVideoEditAttributes } from './videos'
 import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports'
 import { cleanUpReqFiles } from '../../../helpers/express-utils'
-import { isVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos'
+import { doesVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos'
 import { CONFIG } from '../../../initializers/constants'
 import { CONSTRAINTS_FIELDS } from '../../../initializers'
 
@@ -51,7 +51,7 @@ const videoImportAddValidator = getCommonVideoEditAttributes().concat([
                 .end()
     }
 
-    if (!await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
+    if (!await doesVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
 
     // Check we have at least 1 required param
     if (!req.body.targetUrl && !req.body.magnetUri && !torrentFile) {
index 5f33e2d4971112b9ce2af7a9f6b5baba3d755996..4bc79f433b8584c9d3b591c528cc94dc2690e378 100644 (file)
@@ -4,12 +4,12 @@ import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../..
 import { logger } from '../../../helpers/logger'
 import { UserModel } from '../../../models/account/user'
 import { areValidationErrors } from '../utils'
-import { isVideoExist, isVideoImage } from '../../../helpers/custom-validators/videos'
+import { doesVideoExist, isVideoImage } from '../../../helpers/custom-validators/videos'
 import { CONSTRAINTS_FIELDS } from '../../../initializers'
 import { isArrayOf, isIdOrUUIDValid, isIdValid, isUUIDValid, toIntArray, toValueOrNull } from '../../../helpers/custom-validators/misc'
 import {
   isVideoPlaylistDescriptionValid,
-  isVideoPlaylistExist,
+  doesVideoPlaylistExist,
   isVideoPlaylistNameValid,
   isVideoPlaylistPrivacyValid,
   isVideoPlaylistTimestampValid,
@@ -17,7 +17,7 @@ import {
 } from '../../../helpers/custom-validators/video-playlists'
 import { VideoPlaylistModel } from '../../../models/video/video-playlist'
 import { cleanUpReqFiles } from '../../../helpers/express-utils'
-import { isVideoChannelIdExist } from '../../../helpers/custom-validators/video-channels'
+import { doesVideoChannelIdExist } from '../../../helpers/custom-validators/video-channels'
 import { VideoPlaylistElementModel } from '../../../models/video/video-playlist-element'
 import { VideoModel } from '../../../models/video/video'
 import { authenticatePromiseIfNeeded } from '../../oauth'
@@ -31,7 +31,7 @@ const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([
     if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
 
     const body: VideoPlaylistCreate = req.body
-    if (body.videoChannelId && !await isVideoChannelIdExist(body.videoChannelId, res)) return cleanUpReqFiles(req)
+    if (body.videoChannelId && !await doesVideoChannelIdExist(body.videoChannelId, res)) return cleanUpReqFiles(req)
 
     if (body.privacy === VideoPlaylistPrivacy.PUBLIC && !body.videoChannelId) {
       cleanUpReqFiles(req)
@@ -52,7 +52,7 @@ const videoPlaylistsUpdateValidator = getCommonPlaylistEditAttributes().concat([
 
     if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
 
-    if (!await isVideoPlaylistExist(req.params.playlistId, res, 'all')) return cleanUpReqFiles(req)
+    if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return cleanUpReqFiles(req)
 
     const videoPlaylist = res.locals.videoPlaylist
 
@@ -86,7 +86,7 @@ const videoPlaylistsUpdateValidator = getCommonPlaylistEditAttributes().concat([
                 .json({ error: 'Cannot update a watch later playlist.' })
     }
 
-    if (body.videoChannelId && !await isVideoChannelIdExist(body.videoChannelId, res)) return cleanUpReqFiles(req)
+    if (body.videoChannelId && !await doesVideoChannelIdExist(body.videoChannelId, res)) return cleanUpReqFiles(req)
 
     return next()
   }
@@ -101,7 +101,7 @@ const videoPlaylistsDeleteValidator = [
 
     if (areValidationErrors(req, res)) return
 
-    if (!await isVideoPlaylistExist(req.params.playlistId, res)) return
+    if (!await doesVideoPlaylistExist(req.params.playlistId, res)) return
 
     const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
     if (videoPlaylist.type === VideoPlaylistType.WATCH_LATER) {
@@ -126,7 +126,7 @@ const videoPlaylistsGetValidator = [
 
     if (areValidationErrors(req, res)) return
 
-    if (!await isVideoPlaylistExist(req.params.playlistId, res)) return
+    if (!await doesVideoPlaylistExist(req.params.playlistId, res)) return
 
     const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
 
@@ -174,8 +174,8 @@ const videoPlaylistsAddVideoValidator = [
 
     if (areValidationErrors(req, res)) return
 
-    if (!await isVideoPlaylistExist(req.params.playlistId, res, 'all')) return
-    if (!await isVideoExist(req.body.videoId, res, 'only-video')) return
+    if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return
+    if (!await doesVideoExist(req.body.videoId, res, 'only-video')) return
 
     const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
     const video: VideoModel = res.locals.video
@@ -214,8 +214,8 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [
 
     if (areValidationErrors(req, res)) return
 
-    if (!await isVideoPlaylistExist(req.params.playlistId, res, 'all')) return
-    if (!await isVideoExist(req.params.videoId, res, 'id')) return
+    if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return
+    if (!await doesVideoExist(req.params.videoId, res, 'id')) return
 
     const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
     const video: VideoModel = res.locals.video
@@ -282,7 +282,7 @@ const videoPlaylistsReorderVideosValidator = [
 
     if (areValidationErrors(req, res)) return
 
-    if (!await isVideoPlaylistExist(req.params.playlistId, res, 'all')) return
+    if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return
 
     const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist
     if (!checkUserCanManageVideoPlaylist(res.locals.oauth.token.User, videoPlaylist, UserRight.UPDATE_ANY_VIDEO_PLAYLIST, res)) return
index 7933545207a2184b4bfcb12270997940d4976bfb..28038591243b807e8585559c4cc543527e9ba123 100644 (file)
@@ -2,7 +2,7 @@ import * as express from 'express'
 import 'express-validator'
 import { body, param } from 'express-validator/check'
 import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
-import { isVideoExist, isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos'
+import { doesVideoExist, isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos'
 import { logger } from '../../../helpers/logger'
 import { areValidationErrors } from '../utils'
 import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
@@ -17,7 +17,7 @@ const videoUpdateRateValidator = [
     logger.debug('Checking videoRate parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.id, res)) return
+    if (!await doesVideoExist(req.params.id, res)) return
 
     return next()
   }
index 646d7acb16123b47fd3c2da7a95256ea1ddaac81..f4514f85cb35abe75d51e1b6187af5839783b3f6 100644 (file)
@@ -2,7 +2,7 @@ import * as express from 'express'
 import 'express-validator'
 import { param } from 'express-validator/check'
 import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
-import { isVideoExist } from '../../../helpers/custom-validators/videos'
+import { doesVideoExist } from '../../../helpers/custom-validators/videos'
 import { logger } from '../../../helpers/logger'
 import { VideoShareModel } from '../../../models/video/video-share'
 import { areValidationErrors } from '../utils'
@@ -16,7 +16,7 @@ const videosShareValidator = [
     logger.debug('Checking videoShare parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.id, res)) return
+    if (!await doesVideoExist(req.params.id, res)) return
 
     const video: VideoModel = res.locals.video
 
index c38ad8a10d284d18a1e9c3eb288007530ff6fe4f..a3b70c0cc183ef65891feaccda8b91c8145b2d53 100644 (file)
@@ -1,7 +1,7 @@
 import { body, param } from 'express-validator/check'
 import * as express from 'express'
 import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
-import { isVideoExist } from '../../../helpers/custom-validators/videos'
+import { doesVideoExist } from '../../../helpers/custom-validators/videos'
 import { areValidationErrors } from '../utils'
 import { logger } from '../../../helpers/logger'
 import { UserModel } from '../../../models/account/user'
@@ -16,7 +16,7 @@ const videoWatchingValidator = [
     logger.debug('Checking videoWatching parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res, 'id')) return
+    if (!await doesVideoExist(req.params.videoId, res, 'id')) return
 
     const user = res.locals.oauth.token.User as UserModel
     if (user.videosHistoryEnabled === false) {
index a5e3ed0dcf36f41cc9d37be1a40ca8dca93e92e7..92218d4b12e265f485ae892532d2242a28f52595 100644 (file)
@@ -17,9 +17,9 @@ import {
   isVideoOriginallyPublishedAtValid,
   isScheduleVideoUpdatePrivacyValid,
   isVideoCategoryValid,
-  isVideoChannelOfAccountExist,
+  doesVideoChannelOfAccountExist,
   isVideoDescriptionValid,
-  isVideoExist,
+  doesVideoExist,
   isVideoFile,
   isVideoFilterValid,
   isVideoImage,
@@ -66,7 +66,7 @@ const videosAddValidator = getCommonVideoEditAttributes().concat([
     const videoFile: Express.Multer.File = req.files['videofile'][0]
     const user = res.locals.oauth.token.User
 
-    if (!await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
+    if (!await doesVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
 
     const isAble = await user.isAbleToUploadVideo(videoFile)
     if (isAble === false) {
@@ -109,7 +109,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
 
     if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
     if (areErrorsInScheduleUpdate(req, res)) return cleanUpReqFiles(req)
-    if (!await isVideoExist(req.params.id, res)) return cleanUpReqFiles(req)
+    if (!await doesVideoExist(req.params.id, res)) return cleanUpReqFiles(req)
 
     const video = res.locals.video
 
@@ -123,7 +123,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
         .json({ error: 'Cannot set "private" a video that was not private.' })
     }
 
-    if (req.body.channelId && !await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
+    if (req.body.channelId && !await doesVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
 
     return next()
   }
@@ -162,7 +162,7 @@ const videosCustomGetValidator = (fetchType: VideoFetchType) => {
       logger.debug('Checking videosGet parameters', { parameters: req.params })
 
       if (areValidationErrors(req, res)) return
-      if (!await isVideoExist(req.params.id, res, fetchType)) return
+      if (!await doesVideoExist(req.params.id, res, fetchType)) return
 
       const video: VideoModel = res.locals.video
 
@@ -207,7 +207,7 @@ const videosRemoveValidator = [
     logger.debug('Checking videosRemove parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.id, res)) return
+    if (!await doesVideoExist(req.params.id, res)) return
 
     // Check if the user who did the request is able to delete the video
     if (!checkUserCanManageVideo(res.locals.oauth.token.User, res.locals.video, UserRight.REMOVE_ANY_VIDEO, res)) return
@@ -223,7 +223,7 @@ const videosChangeOwnershipValidator = [
     logger.debug('Checking changeOwnership parameters', { parameters: req.params })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
 
     // Check if the user who did the request is able to change the ownership of the video
     if (!checkUserCanManageVideo(res.locals.oauth.token.User, res.locals.video, UserRight.CHANGE_VIDEO_OWNERSHIP, res)) return
@@ -272,7 +272,7 @@ const videosTerminateChangeOwnershipValidator = [
 const videosAcceptChangeOwnershipValidator = [
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
     const body = req.body as VideoChangeOwnershipAccept
-    if (!await isVideoChannelOfAccountExist(body.channelId, res.locals.oauth.token.User, res)) return
+    if (!await doesVideoChannelOfAccountExist(body.channelId, res.locals.oauth.token.User, res)) return
 
     const user = res.locals.oauth.token.User
     const videoChangeOwnership = res.locals.videoChangeOwnership as VideoChangeOwnershipModel