1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Does exist

This commit is contained in:
Chocobozzz 2019-03-19 09:26:50 +01:00
parent 9a18a62520
commit 0f6acda116
No known key found for this signature in database
GPG key ID: 583A612D890159BE
28 changed files with 132 additions and 133 deletions

View 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
}

View 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

View 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
}

View 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
}

View 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) {

View 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
}

View 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,

View 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
}