From 74dc3bca2b14f5fd3fe80c394dfc34177a46db77 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Apr 2019 14:26:41 +0200 Subject: Don't expose constants directly in initializers/ --- server/helpers/activitypub.ts | 2 +- server/helpers/core-utils.ts | 3 +-- server/helpers/custom-validators/activitypub/actor.ts | 2 +- server/helpers/custom-validators/activitypub/misc.ts | 2 +- server/helpers/custom-validators/activitypub/video-comments.ts | 4 ++-- server/helpers/custom-validators/activitypub/videos.ts | 2 +- server/helpers/custom-validators/servers.ts | 2 +- server/helpers/custom-validators/users.ts | 2 +- server/helpers/custom-validators/video-abuses.ts | 2 +- server/helpers/custom-validators/video-blacklist.ts | 2 +- server/helpers/custom-validators/video-captions.ts | 2 +- server/helpers/custom-validators/video-channels.ts | 2 +- server/helpers/custom-validators/video-comments.ts | 2 +- server/helpers/custom-validators/video-imports.ts | 2 +- server/helpers/custom-validators/video-playlists.ts | 2 +- server/helpers/custom-validators/videos.ts | 2 +- server/helpers/custom-validators/webfinger.ts | 2 +- server/helpers/express-utils.ts | 2 +- server/helpers/peertube-crypto.ts | 2 +- server/helpers/requests.ts | 2 +- server/helpers/youtube-dl.ts | 2 +- 21 files changed, 22 insertions(+), 23 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index 0c303c369..951a25669 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts @@ -2,7 +2,7 @@ import * as Bluebird from 'bluebird' import * as validator from 'validator' import { ResultList } from '../../shared/models' import { Activity } from '../../shared/models/activitypub' -import { ACTIVITY_PUB } from '../initializers' +import { ACTIVITY_PUB } from '../initializers/constants' import { ActorModel } from '../models/activitypub/actor' import { signJsonLDObject } from './peertube-crypto' import { pageToStartAndCount } from './core-utils' diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index 3f737c1d6..f6d90bfca 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts @@ -11,14 +11,13 @@ import * as pem from 'pem' import { URL } from 'url' import { truncate } from 'lodash' import { exec } from 'child_process' -import { isArray } from './custom-validators/misc' const objectConverter = (oldObject: any, keyConverter: (e: string) => string, valueConverter: (e: any) => any) => { if (!oldObject || typeof oldObject !== 'object') { return valueConverter(oldObject) } - if (isArray(oldObject)) { + if (Array.isArray(oldObject)) { return oldObject.map(e => objectConverter(e, keyConverter, valueConverter)) } diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts index c05f60f14..deb331abb 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/helpers/custom-validators/activitypub/actor.ts @@ -1,5 +1,5 @@ import * as validator from 'validator' -import { CONSTRAINTS_FIELDS } from '../../../initializers' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' import { exists, isArray } from '../misc' import { truncate } from 'lodash' import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc' diff --git a/server/helpers/custom-validators/activitypub/misc.ts b/server/helpers/custom-validators/activitypub/misc.ts index f1762d11c..f9445929b 100644 --- a/server/helpers/custom-validators/activitypub/misc.ts +++ b/server/helpers/custom-validators/activitypub/misc.ts @@ -1,5 +1,5 @@ import * as validator from 'validator' -import { CONSTRAINTS_FIELDS } from '../../../initializers' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' import { isTestInstance } from '../../core-utils' import { exists } from '../misc' diff --git a/server/helpers/custom-validators/activitypub/video-comments.ts b/server/helpers/custom-validators/activitypub/video-comments.ts index 0415db21c..26c8c4cc6 100644 --- a/server/helpers/custom-validators/activitypub/video-comments.ts +++ b/server/helpers/custom-validators/activitypub/video-comments.ts @@ -1,7 +1,7 @@ import * as validator from 'validator' -import { ACTIVITY_PUB, CONSTRAINTS_FIELDS } from '../../../initializers' +import { ACTIVITY_PUB } from '../../../initializers/constants' import { exists, isArray, isDateValid } from '../misc' -import { isActivityPubUrlValid, isBaseActivityValid } from './misc' +import { isActivityPubUrlValid } from './misc' function sanitizeAndCheckVideoCommentObject (comment: any) { if (!comment || comment.type !== 'Note') return false diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index d94333151..3ba6b0744 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts @@ -1,5 +1,5 @@ import * as validator from 'validator' -import { ACTIVITY_PUB, CONSTRAINTS_FIELDS } from '../../../initializers' +import { ACTIVITY_PUB, CONSTRAINTS_FIELDS } from '../../../initializers/constants' import { peertubeTruncate } from '../../core-utils' import { exists, isArray, isBooleanValid, isDateValid, isUUIDValid } from '../misc' import { diff --git a/server/helpers/custom-validators/servers.ts b/server/helpers/custom-validators/servers.ts index 18c80ec8f..5c8bf0d2d 100644 --- a/server/helpers/custom-validators/servers.ts +++ b/server/helpers/custom-validators/servers.ts @@ -3,7 +3,7 @@ import 'express-validator' import { isArray, exists } from './misc' import { isTestInstance } from '../core-utils' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' function isHostValid (host: string) { const isURLOptions = { diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 80652b479..70af5f1f0 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -1,7 +1,7 @@ import 'express-validator' import * as validator from 'validator' import { UserRole } from '../../../shared' -import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers' +import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' import { exists, isFileValid, isBooleanValid } from './misc' import { values } from 'lodash' diff --git a/server/helpers/custom-validators/video-abuses.ts b/server/helpers/custom-validators/video-abuses.ts index 71500fde5..a61dcee1c 100644 --- a/server/helpers/custom-validators/video-abuses.ts +++ b/server/helpers/custom-validators/video-abuses.ts @@ -1,6 +1,6 @@ import { Response } from 'express' import * as validator from 'validator' -import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers' +import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants' import { exists } from './misc' import { VideoAbuseModel } from '../../models/video/video-abuse' diff --git a/server/helpers/custom-validators/video-blacklist.ts b/server/helpers/custom-validators/video-blacklist.ts index 465f58a9c..3743f7023 100644 --- a/server/helpers/custom-validators/video-blacklist.ts +++ b/server/helpers/custom-validators/video-blacklist.ts @@ -1,7 +1,7 @@ import { Response } from 'express' import * as validator from 'validator' import { exists } from './misc' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { VideoBlacklistModel } from '../../models/video/video-blacklist' import { VideoBlacklistType } from '../../../shared/models/videos' diff --git a/server/helpers/custom-validators/video-captions.ts b/server/helpers/custom-validators/video-captions.ts index 8bd139003..3b6569a8a 100644 --- a/server/helpers/custom-validators/video-captions.ts +++ b/server/helpers/custom-validators/video-captions.ts @@ -1,4 +1,4 @@ -import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers' +import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' import { exists, isFileValid } from './misc' import { Response } from 'express' import { VideoModel } from '../../models/video/video' diff --git a/server/helpers/custom-validators/video-channels.ts b/server/helpers/custom-validators/video-channels.ts index ca8d207cf..fd56b9a70 100644 --- a/server/helpers/custom-validators/video-channels.ts +++ b/server/helpers/custom-validators/video-channels.ts @@ -2,7 +2,7 @@ import * as express from 'express' import 'express-validator' import 'multer' import * as validator from 'validator' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { VideoChannelModel } from '../../models/video/video-channel' import { exists } from './misc' diff --git a/server/helpers/custom-validators/video-comments.ts b/server/helpers/custom-validators/video-comments.ts index 2b3f66063..0707e2af2 100644 --- a/server/helpers/custom-validators/video-comments.ts +++ b/server/helpers/custom-validators/video-comments.ts @@ -1,7 +1,7 @@ import 'express-validator' import 'multer' import * as validator from 'validator' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' const VIDEO_COMMENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_COMMENTS diff --git a/server/helpers/custom-validators/video-imports.ts b/server/helpers/custom-validators/video-imports.ts index 14db9b534..f4235e2fa 100644 --- a/server/helpers/custom-validators/video-imports.ts +++ b/server/helpers/custom-validators/video-imports.ts @@ -1,7 +1,7 @@ import 'express-validator' import 'multer' import * as validator from 'validator' -import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers' +import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants' import { exists, isFileValid } from './misc' import * as express from 'express' import { VideoImportModel } from '../../models/video/video-import' diff --git a/server/helpers/custom-validators/video-playlists.ts b/server/helpers/custom-validators/video-playlists.ts index c962c5532..2fe426560 100644 --- a/server/helpers/custom-validators/video-playlists.ts +++ b/server/helpers/custom-validators/video-playlists.ts @@ -1,6 +1,6 @@ import { exists } from './misc' import * as validator from 'validator' -import { CONSTRAINTS_FIELDS, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES } from '../../initializers' +import { CONSTRAINTS_FIELDS, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES } from '../../initializers/constants' import * as express from 'express' import { VideoPlaylistModel } from '../../models/video/video-playlist' diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index dd9d62d24..eb08ae4ad 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -11,7 +11,7 @@ import { VIDEO_PRIVACIES, VIDEO_RATE_TYPES, VIDEO_STATES -} from '../../initializers' +} from '../../initializers/constants' import { VideoModel } from '../../models/video/video' import { exists, isArray, isDateValid, isFileValid } from './misc' import { VideoChannelModel } from '../../models/video/video-channel' diff --git a/server/helpers/custom-validators/webfinger.ts b/server/helpers/custom-validators/webfinger.ts index b18e43fad..dd914341e 100644 --- a/server/helpers/custom-validators/webfinger.ts +++ b/server/helpers/custom-validators/webfinger.ts @@ -1,4 +1,4 @@ -import { REMOTE_SCHEME, WEBSERVER } from '../../initializers' +import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants' import { sanitizeHost } from '../core-utils' import { exists } from './misc' diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts index 2b574ab8e..e0a1d56a5 100644 --- a/server/helpers/express-utils.ts +++ b/server/helpers/express-utils.ts @@ -1,6 +1,6 @@ import * as express from 'express' import * as multer from 'multer' -import { REMOTE_SCHEME } from '../initializers' +import { REMOTE_SCHEME } from '../initializers/constants' import { logger } from './logger' import { deleteFileAsync, generateRandomString } from './utils' import { extname } from 'path' diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts index ab9ec077e..9148df2eb 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/helpers/peertube-crypto.ts @@ -1,5 +1,5 @@ import { Request } from 'express' -import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers' +import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants' import { ActorModel } from '../models/activitypub/actor' import { bcryptComparePromise, bcryptGenSaltPromise, bcryptHashPromise, createPrivateKey, getPublicKey, sha256 } from './core-utils' import { jsig, jsonld } from './custom-jsonld-signature' diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 02854b164..60c94da81 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -1,7 +1,7 @@ import * as Bluebird from 'bluebird' import { createWriteStream, remove } from 'fs-extra' import * as request from 'request' -import { ACTIVITY_PUB } from '../initializers' +import { ACTIVITY_PUB } from '../initializers/constants' import { processImage } from './image-utils' import { join } from 'path' import { logger } from './logger' diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index c188739ff..b3079370f 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts @@ -1,5 +1,5 @@ import { truncate } from 'lodash' -import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers' +import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers/constants' import { logger } from './logger' import { generateVideoImportTmpPath } from './utils' import { join } from 'path' -- cgit v1.2.3