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()
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)
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)) {
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) {
export {
isAccountIdValid,
- isAccountIdExist,
- isLocalAccountNameExist,
+ doesAccountIdExist,
+ doesLocalAccountNameExist,
isAccountDescriptionValid,
- isAccountNameWithHostExist,
+ doesAccountNameWithHostExist,
isAccountNameValid
}
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) {
// ---------------------------------------------------------------------------
export {
- isVideoAbuseExist,
+ doesVideoAbuseExist,
isVideoAbuseStateValid,
isVideoAbuseReasonValid,
isVideoAbuseModerationCommentValid
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) {
export {
isVideoBlacklistReasonValid,
- isVideoBlacklistExist
+ doesVideoBlacklistExist
}
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) {
export {
isVideoCaptionFile,
isVideoCaptionLanguageValid,
- isVideoCaptionExist
+ doesVideoCaptionExist
}
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)
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)
// ---------------------------------------------------------------------------
export {
- isVideoChannelNameWithHostExist,
- isLocalVideoChannelNameExist,
+ doesVideoChannelNameWithHostExist,
+ doesLocalVideoChannelNameExist,
isVideoChannelDescriptionValid,
isVideoChannelNameValid,
isVideoChannelSupportValid,
- isVideoChannelIdExist
+ doesVideoChannelIdExist
}
function processVideoChannelExist (videoChannel: VideoChannelModel, res: express.Response) {
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) {
export {
isVideoImportStateValid,
isVideoImportTargetUrlValid,
- isVideoImportExist,
+ doesVideoImportExist,
isVideoImportTorrentFile
}
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)
// ---------------------------------------------------------------------------
export {
- isVideoPlaylistExist,
+ doesVideoPlaylistExist,
isVideoPlaylistNameValid,
isVideoPlaylistDescriptionValid,
isVideoPlaylistPrivacyValid,
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)
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) {
isVideoPrivacyValid,
isVideoFileResolutionValid,
isVideoFileSizeValid,
- isVideoExist,
+ doesVideoExist,
isVideoImage,
- isVideoChannelOfAccountExist,
+ doesVideoChannelOfAccountExist,
isVideoSupportValid,
isVideoFilterValid
}
return this.setValue(this.generateContactFormKey(ip), '1', CONTACT_FORM_LIFETIME)
}
- async isContactFormIpExists (ip: string) {
+ async doesContactFormIpExist (ip: string) {
return this.exists(this.generateContactFormKey(ip))
}
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))
}
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'
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()
}
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()
}
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'
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
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()
}
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()
}
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()
}
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()
}
// ---------------------------------------------------------------------------
-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)
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)
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 = [
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()
}
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()
}
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'
.end()
}
- if (!await isVideoExist(videoId, res)) return
+ if (!await doesVideoExist(videoId, res)) return
return next()
}
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'
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 => {
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)
.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
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'
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()
}
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
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()
}
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()
}
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()
}
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 = [
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()
}
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) {
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()
}
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 = [
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
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
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()
}
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'
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) {
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
if (areValidationErrors(req, res)) return
- if (!await isVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
+ if (!await doesVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
return next()
}
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()
}
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'
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()
}
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()
}
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()
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()
}
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()
}
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
// ---------------------------------------------------------------------------
-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) {
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) {
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'
.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) {
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,
} 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'
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)
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
.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()
}
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) {
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 (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
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
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
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'
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()
}
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'
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
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'
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) {
isVideoOriginallyPublishedAtValid,
isScheduleVideoUpdatePrivacyValid,
isVideoCategoryValid,
- isVideoChannelOfAccountExist,
+ doesVideoChannelOfAccountExist,
isVideoDescriptionValid,
- isVideoExist,
+ doesVideoExist,
isVideoFile,
isVideoFilterValid,
isVideoImage,
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) {
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
.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()
}
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
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
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
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