From 608624252466acf9f1d9ee1c1170bd4fe4d18d18 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Nov 2017 11:00:25 +0100 Subject: Rename Pod -> Server --- server/helpers/custom-validators/accounts.ts | 2 +- server/helpers/custom-validators/index.ts | 4 ++-- server/helpers/custom-validators/pods.ts | 34 ---------------------------- server/helpers/custom-validators/servers.ts | 34 ++++++++++++++++++++++++++++ server/helpers/custom-validators/videos.ts | 4 ++-- 5 files changed, 39 insertions(+), 39 deletions(-) delete mode 100644 server/helpers/custom-validators/pods.ts create mode 100644 server/helpers/custom-validators/servers.ts (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts index 6d6219a95..088d5fc8f 100644 --- a/server/helpers/custom-validators/accounts.ts +++ b/server/helpers/custom-validators/accounts.ts @@ -8,7 +8,7 @@ import { AccountInstance } from '../../models' import { logger } from '../logger' import { isUserUsernameValid } from './users' -import { isHostValid } from './pods' +import { isHostValid } from './servers' function isAccountNameValid (value: string) { return isUserUsernameValid(value) diff --git a/server/helpers/custom-validators/index.ts b/server/helpers/custom-validators/index.ts index 1c475e301..d3b2f5393 100644 --- a/server/helpers/custom-validators/index.ts +++ b/server/helpers/custom-validators/index.ts @@ -1,7 +1,7 @@ export * from './activitypub' export * from './misc' -export * from './pods' -export * from './pods' +export * from './servers' +export * from './servers' export * from './users' export * from './accounts' export * from './video-channels' diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts deleted file mode 100644 index d5021bf38..000000000 --- a/server/helpers/custom-validators/pods.ts +++ /dev/null @@ -1,34 +0,0 @@ -import * as validator from 'validator' -import 'express-validator' - -import { isArray, exists } from './misc' -import { isTestInstance } from '../core-utils' - -function isHostValid (host: string) { - const isURLOptions = { - require_host: true, - require_tld: true - } - - // We validate 'localhost', so we don't have the top level domain - if (isTestInstance()) { - isURLOptions.require_tld = false - } - - return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1 -} - -function isEachUniqueHostValid (hosts: string[]) { - return isArray(hosts) && - hosts.length !== 0 && - hosts.every(host => { - return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host) - }) -} - -// --------------------------------------------------------------------------- - -export { - isEachUniqueHostValid, - isHostValid -} diff --git a/server/helpers/custom-validators/servers.ts b/server/helpers/custom-validators/servers.ts new file mode 100644 index 000000000..d5021bf38 --- /dev/null +++ b/server/helpers/custom-validators/servers.ts @@ -0,0 +1,34 @@ +import * as validator from 'validator' +import 'express-validator' + +import { isArray, exists } from './misc' +import { isTestInstance } from '../core-utils' + +function isHostValid (host: string) { + const isURLOptions = { + require_host: true, + require_tld: true + } + + // We validate 'localhost', so we don't have the top level domain + if (isTestInstance()) { + isURLOptions.require_tld = false + } + + return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1 +} + +function isEachUniqueHostValid (hosts: string[]) { + return isArray(hosts) && + hosts.length !== 0 && + hosts.every(host => { + return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host) + }) +} + +// --------------------------------------------------------------------------- + +export { + isEachUniqueHostValid, + isHostValid +} diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 715119cf6..d68de6609 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -171,9 +171,9 @@ function isVideoFileInfoHashValid (value: string) { function checkVideoExists (id: string, res: express.Response, callback: () => void) { let promise: Promise if (validator.isInt(id)) { - promise = db.Video.loadAndPopulateAccountAndPodAndTags(+id) + promise = db.Video.loadAndPopulateAccountAndServerAndTags(+id) } else { // UUID - promise = db.Video.loadByUUIDAndPopulateAccountAndPodAndTags(id) + promise = db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(id) } promise.then(video => { -- cgit v1.2.3