From 74dc3bca2b14f5fd3fe80c394dfc34177a46db77 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Apr 2019 14:26:41 +0200 Subject: [PATCH] Don't expose constants directly in initializers/ --- scripts/danger/clean/cleaner.ts | 3 +- scripts/optimize-old-videos.ts | 9 +++--- scripts/parse-log.ts | 2 +- scripts/prune-storage.ts | 2 +- scripts/update-host.ts | 12 ++++--- server.ts | 32 +++++++++++++------ server/controllers/activitypub/client.ts | 2 +- server/controllers/api/config.ts | 2 +- server/controllers/api/overviews.ts | 2 +- server/controllers/api/server/follows.ts | 3 +- server/controllers/api/server/logs.ts | 2 +- server/controllers/api/users/index.ts | 3 +- server/controllers/api/users/me.ts | 3 +- .../controllers/api/users/my-subscriptions.ts | 3 +- server/controllers/api/video-channel.ts | 3 +- server/controllers/api/video-playlist.ts | 3 +- server/controllers/api/videos/captions.ts | 3 +- server/controllers/api/videos/import.ts | 3 +- server/controllers/api/videos/index.ts | 4 +-- server/controllers/api/videos/rate.ts | 3 +- server/controllers/bots.ts | 2 +- server/controllers/client.ts | 2 +- server/controllers/feeds.ts | 3 +- server/controllers/services.ts | 3 +- server/controllers/static.ts | 2 +- server/helpers/activitypub.ts | 2 +- server/helpers/core-utils.ts | 3 +- .../custom-validators/activitypub/actor.ts | 2 +- .../custom-validators/activitypub/misc.ts | 2 +- .../activitypub/video-comments.ts | 4 +-- .../custom-validators/activitypub/videos.ts | 2 +- server/helpers/custom-validators/servers.ts | 2 +- server/helpers/custom-validators/users.ts | 2 +- .../helpers/custom-validators/video-abuses.ts | 2 +- .../custom-validators/video-blacklist.ts | 2 +- .../custom-validators/video-captions.ts | 2 +- .../custom-validators/video-channels.ts | 2 +- .../custom-validators/video-comments.ts | 2 +- .../custom-validators/video-imports.ts | 2 +- .../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 +- server/initializers/constants.ts | 7 +++- server/initializers/index.ts | 2 -- .../migrations/0170-actor-follow-score.ts | 2 +- .../migrations/0210-video-language.ts | 2 +- .../migrations/0215-video-support-length.ts | 1 - server/lib/activitypub/actor.ts | 3 +- server/lib/activitypub/audience.ts | 2 +- server/lib/activitypub/crawl.ts | 2 +- server/lib/activitypub/playlist.ts | 3 +- server/lib/activitypub/share.ts | 2 +- server/lib/activitypub/url.ts | 2 +- server/lib/activitypub/video-comments.ts | 2 +- server/lib/activitypub/video-rates.ts | 2 +- server/lib/activitypub/videos.ts | 10 ++---- server/lib/avatar.ts | 3 +- server/lib/client-html.ts | 2 +- .../files-cache/actor-follow-score-cache.ts | 2 +- .../lib/files-cache/videos-caption-cache.ts | 2 +- .../lib/files-cache/videos-preview-cache.ts | 2 +- server/lib/hls.ts | 3 +- .../job-queue/handlers/activitypub-follow.ts | 3 +- .../handlers/activitypub-http-broadcast.ts | 2 +- .../handlers/activitypub-http-unicast.ts | 2 +- .../handlers/utils/activitypub-http-utils.ts | 2 +- server/lib/job-queue/handlers/video-import.ts | 3 +- server/lib/job-queue/job-queue.ts | 2 +- server/lib/redis.ts | 2 +- .../lib/schedulers/actor-follow-scheduler.ts | 2 +- .../schedulers/remove-old-jobs-scheduler.ts | 2 +- .../lib/schedulers/update-videos-scheduler.ts | 3 +- .../schedulers/videos-redundancy-scheduler.ts | 2 +- .../schedulers/youtube-dl-update-scheduler.ts | 2 +- server/lib/user.ts | 3 +- server/lib/video-transcoding.ts | 2 +- server/middlewares/activitypub.ts | 2 +- server/middlewares/oauth.ts | 2 +- server/middlewares/pagination.ts | 2 +- server/middlewares/validators/avatar.ts | 2 +- server/middlewares/validators/follows.ts | 2 +- server/middlewares/validators/sort.ts | 2 +- .../validators/videos/video-captions.ts | 2 +- .../validators/videos/video-channels.ts | 3 +- .../validators/videos/video-imports.ts | 2 +- .../validators/videos/video-playlists.ts | 2 +- .../middlewares/validators/videos/videos.ts | 2 +- server/models/account/account-video-rate.ts | 2 +- server/models/account/user.ts | 2 +- server/models/activitypub/actor-follow.ts | 2 +- server/models/activitypub/actor.ts | 2 +- server/models/avatar/avatar.ts | 2 +- server/models/redundancy/video-redundancy.ts | 2 +- server/models/utils.ts | 1 - server/models/video/video-abuse.ts | 2 +- server/models/video/video-blacklist.ts | 2 +- server/models/video/video-caption.ts | 2 +- server/models/video/video-channel.ts | 2 +- server/models/video/video-comment.ts | 2 +- server/models/video/video-format-utils.ts | 2 +- server/models/video/video-import.ts | 2 +- server/models/video/video-playlist-element.ts | 2 +- server/models/video/video-playlist.ts | 2 +- server/models/video/video-share.ts | 2 +- .../models/video/video-streaming-playlist.ts | 2 +- server/models/video/video.ts | 2 +- server/tests/api/activitypub/security.ts | 2 +- server/tests/cli/optimize-old-videos.ts | 2 +- server/tools/peertube-import-videos.ts | 2 +- shared/utils/requests/activitypub.ts | 2 +- 114 files changed, 168 insertions(+), 144 deletions(-) diff --git a/scripts/danger/clean/cleaner.ts b/scripts/danger/clean/cleaner.ts index 009f8f7a0..d575af283 100644 --- a/scripts/danger/clean/cleaner.ts +++ b/scripts/danger/clean/cleaner.ts @@ -1,6 +1,7 @@ import * as Promise from 'bluebird' import * as rimraf from 'rimraf' -import { CONFIG, initDatabaseModels, sequelizeTypescript } from '../../../server/initializers' +import { initDatabaseModels, sequelizeTypescript } from '../../../server/initializers' +import { CONFIG } from '../../../server/initializers/config' initDatabaseModels(true) .then(() => { diff --git a/scripts/optimize-old-videos.ts b/scripts/optimize-old-videos.ts index 1bee1b0f3..a1d5345a1 100644 --- a/scripts/optimize-old-videos.ts +++ b/scripts/optimize-old-videos.ts @@ -1,11 +1,12 @@ -import { CONFIG, VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' -import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution, getDurationFromVideoFile } from '../server/helpers/ffmpeg-utils' +import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' +import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils' import { getMaxBitrate } from '../shared/models/videos' import { VideoModel } from '../server/models/video/video' import { optimizeVideofile } from '../server/lib/video-transcoding' import { initDatabaseModels } from '../server/initializers' -import { join, basename, dirname } from 'path' -import { copy, remove, move } from 'fs-extra' +import { basename, dirname, join } from 'path' +import { copy, move, remove } from 'fs-extra' +import { CONFIG } from '../server/initializers/config' run() .then(() => process.exit(0)) diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts index 66a5b8719..fe87db009 100755 --- a/scripts/parse-log.ts +++ b/scripts/parse-log.ts @@ -4,7 +4,7 @@ import { join } from 'path' import { createInterface } from 'readline' import * as winston from 'winston' import { labelFormatter } from '../server/helpers/logger' -import { CONFIG } from '../server/initializers/constants' +import { CONFIG } from '../server/initializers/config' import { mtimeSortFilesDesc } from '../shared/utils/logs/logs' program diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index c9e4dbd4b..4953a7439 100755 --- a/scripts/prune-storage.ts +++ b/scripts/prune-storage.ts @@ -1,6 +1,6 @@ import * as prompt from 'prompt' import { join } from 'path' -import { CONFIG } from '../server/initializers/constants' +import { CONFIG } from '../server/initializers/config' import { VideoModel } from '../server/models/video/video' import { initDatabaseModels } from '../server/initializers' import { remove, readdir } from 'fs-extra' diff --git a/scripts/update-host.ts b/scripts/update-host.ts index 64eba867a..57919b998 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts @@ -1,11 +1,12 @@ -import { CONFIG, initDatabaseModels } from '../server/initializers' +import { WEBSERVER } from '../server/initializers/constants' import { ActorFollowModel } from '../server/models/activitypub/actor-follow' import { VideoModel } from '../server/models/video/video' import { ActorModel } from '../server/models/activitypub/actor' import { getAccountActivityPubUrl, + getVideoActivityPubUrl, getVideoAnnounceActivityPubUrl, - getVideoActivityPubUrl, getVideoChannelActivityPubUrl, + getVideoChannelActivityPubUrl, getVideoCommentActivityPubUrl } from '../server/lib/activitypub' import { VideoShareModel } from '../server/models/video/video-share' @@ -14,6 +15,7 @@ import { getServerActor } from '../server/helpers/utils' import { AccountModel } from '../server/models/account/account' import { VideoChannelModel } from '../server/models/video/video-channel' import { VideoStreamingPlaylistModel } from '../server/models/video/video-streaming-playlist' +import { initDatabaseModels } from '../server/initializers' run() .then(() => process.exit(0)) @@ -62,7 +64,7 @@ async function run () { actor.url = newUrl actor.inboxUrl = newUrl + '/inbox' actor.outboxUrl = newUrl + '/outbox' - actor.sharedInboxUrl = CONFIG.WEBSERVER.URL + '/inbox' + actor.sharedInboxUrl = WEBSERVER.URL + '/inbox' actor.followersUrl = newUrl + '/followers' actor.followingUrl = newUrl + '/following' @@ -123,8 +125,8 @@ async function run () { } for (const playlist of video.VideoStreamingPlaylists) { - playlist.playlistUrl = CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) - playlist.segmentsSha256Url = CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid) + playlist.playlistUrl = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) + playlist.segmentsSha256Url = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid) await playlist.save() } diff --git a/server.ts b/server.ts index dfaa8ad3d..110ae1ab8 100644 --- a/server.ts +++ b/server.ts @@ -28,7 +28,8 @@ import { checkMissedConfig, checkFFmpeg } from './server/initializers/checker-be // Do not use barrels because we don't want to load all modules here (we need to initialize database first) import { logger } from './server/helpers/logger' -import { API_VERSION, CONFIG, FILES_CACHE } from './server/initializers/constants' +import { API_VERSION, FILES_CACHE, WEBSERVER, loadLanguages } from './server/initializers/constants' +import { CONFIG } from './server/initializers/config' const missed = checkMissedConfig() if (missed.length !== 0) { @@ -78,6 +79,9 @@ migrate() process.exit(-1) }) +// ----------- Initialize ----------- +loadLanguages() + // ----------- PeerTube modules ----------- import { installApplication } from './server/initializers' import { Emailer } from './server/lib/emailer' @@ -121,20 +125,26 @@ if (isTestInstance()) { credentials: true })) } + // For the logger morgan.token('remote-addr', req => { - return (req.get('DNT') === '1') ? - anonymize(req.ip || (req.connection && req.connection.remoteAddress) || undefined, - 16, // bitmask for IPv4 - 16 // bitmask for IPv6 - ) : - req.ip + if (req.get('DNT') === '1') { + return anonymize(req.ip, 16, 16) + } + + return req.ip +}) +morgan.token('user-agent', req => { + if (req.get('DNT') === '1') { + return useragent.parse(req.get('user-agent')).family + } + + return req.get('user-agent') }) -morgan.token('user-agent', req => (req.get('DNT') === '1') ? - useragent.parse(req.get('user-agent')).family : req.get('user-agent')) app.use(morgan('combined', { stream: { write: logger.info.bind(logger) } })) + // For body requests app.use(bodyParser.urlencoded({ extended: false })) app.use(bodyParser.json({ @@ -145,8 +155,10 @@ app.use(bodyParser.json({ if (valid !== true) throw new Error('Invalid digest') } })) + // Cookies app.use(cookieParser()) + // W3C DNT Tracking Status app.use(advertiseDoNotTrack) @@ -240,7 +252,7 @@ async function startApplication () { // Make server listening server.listen(port, hostname, () => { logger.info('Server listening on %s:%d', hostname, port) - logger.info('Web server: %s', CONFIG.WEBSERVER.URL) + logger.info('Web server: %s', WEBSERVER.URL) }) process.on('exit', () => { diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index f47fae766..d36d10de1 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts @@ -2,7 +2,7 @@ import * as express from 'express' import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' -import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants' import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' import { audiencify, getAudience } from '../../lib/activitypub/audience' import { buildCreateActivity } from '../../lib/activitypub/send/send-create' diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index cdbccaa7d..40012c03b 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -4,7 +4,7 @@ import { ServerConfig, UserRight } from '../../../shared' import { About } from '../../../shared/models/server/about.model' import { CustomConfig } from '../../../shared/models/server/custom-config.model' import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' import { customConfigUpdateValidator } from '../../middlewares/validators/config' import { ClientHtml } from '../../lib/client-html' diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts index b052acdb7..37ac152db 100644 --- a/server/controllers/api/overviews.ts +++ b/server/controllers/api/overviews.ts @@ -4,7 +4,7 @@ import { VideoModel } from '../../models/video/video' import { asyncMiddleware } from '../../middlewares' import { TagModel } from '../../models/video/tag' import { VideosOverview } from '../../../shared/models/overviews' -import { MEMOIZE_TTL, OVERVIEWS, ROUTE_CACHE_LIFETIME } from '../../initializers' +import { MEMOIZE_TTL, OVERVIEWS, ROUTE_CACHE_LIFETIME } from '../../initializers/constants' import { cacheRoute } from '../../middlewares/cache' import * as memoizee from 'memoizee' diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 207a09a4c..d38ce91de 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts @@ -2,7 +2,7 @@ import * as express from 'express' import { UserRight } from '../../../../shared/models/users' import { logger } from '../../../helpers/logger' import { getFormattedObjects, getServerActor } from '../../../helpers/utils' -import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../../../initializers' +import { SERVER_ACTOR_NAME } from '../../../initializers/constants' import { sendAccept, sendReject, sendUndoFollow } from '../../../lib/activitypub/send' import { asyncMiddleware, @@ -24,6 +24,7 @@ import { import { ActorFollowModel } from '../../../models/activitypub/actor-follow' import { JobQueue } from '../../../lib/job-queue' import { removeRedundancyOf } from '../../../lib/redundancy' +import { sequelizeTypescript } from '../../../initializers/database' const serverFollowsRouter = express.Router() serverFollowsRouter.get('/following', diff --git a/server/controllers/api/server/logs.ts b/server/controllers/api/server/logs.ts index bbbfa1d80..03941cca7 100644 --- a/server/controllers/api/server/logs.ts +++ b/server/controllers/api/server/logs.ts @@ -3,7 +3,7 @@ import { UserRight } from '../../../../shared/models/users' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' import { mtimeSortFilesDesc } from '../../../../shared/utils/logs/logs' import { readdir, readFile } from 'fs-extra' -import { MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers' +import { MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers/constants' import { join } from 'path' import { getLogsValidator } from '../../../middlewares/validators/logs' import { LogLevel } from '../../../../shared/models/server/log-level.type' diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index a049e23e4..28c8de303 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts @@ -3,7 +3,7 @@ import * as RateLimit from 'express-rate-limit' import { UserCreate, UserRight, UserRole, UserUpdate } from '../../../../shared' import { logger } from '../../../helpers/logger' import { getFormattedObjects } from '../../../helpers/utils' -import { RATES_LIMIT, sequelizeTypescript, WEBSERVER } from '../../../initializers' +import { RATES_LIMIT, WEBSERVER } from '../../../initializers/constants' import { Emailer } from '../../../lib/emailer' import { Redis } from '../../../lib/redis' import { createUserAccountAndChannelAndPlaylist } from '../../../lib/user' @@ -44,6 +44,7 @@ import { myNotificationsRouter } from './my-notifications' import { Notifier } from '../../../lib/notifier' import { mySubscriptionsRouter } from './my-subscriptions' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const auditLogger = auditLoggerFactory('users') diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 1d1588eca..ce9e78463 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -2,7 +2,7 @@ import * as express from 'express' import 'multer' import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' import { getFormattedObjects } from '../../../helpers/utils' -import { MIMETYPES, sequelizeTypescript } from '../../../initializers' +import { MIMETYPES } from '../../../initializers/constants' import { sendUpdateActor } from '../../../lib/activitypub/send' import { asyncMiddleware, @@ -27,6 +27,7 @@ import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../h import { VideoImportModel } from '../../../models/video/video-import' import { AccountModel } from '../../../models/account/account' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const auditLogger = auditLoggerFactory('users-me') diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index 59b906a8b..c52df3154 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts @@ -1,7 +1,7 @@ import * as express from 'express' import 'multer' import { getFormattedObjects } from '../../../helpers/utils' -import { sequelizeTypescript, WEBSERVER } from '../../../initializers' +import { WEBSERVER } from '../../../initializers/constants' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -20,6 +20,7 @@ import { VideoFilter } from '../../../../shared/models/videos/video-query.type' import { ActorFollowModel } from '../../../models/activitypub/actor-follow' import { JobQueue } from '../../../lib/job-queue' import { logger } from '../../../helpers/logger' +import { sequelizeTypescript } from '../../../initializers/database' const mySubscriptionsRouter = express.Router() diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index b79ce9cec..3d6dbfe70 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts @@ -23,7 +23,7 @@ import { createVideoChannel } from '../../lib/video-channel' import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' import { setAsyncActorKeys } from '../../lib/activitypub' import { AccountModel } from '../../models/account/account' -import { MIMETYPES, sequelizeTypescript } from '../../initializers' +import { MIMETYPES } from '../../initializers/constants' import { logger } from '../../helpers/logger' import { VideoModel } from '../../models/video/video' import { updateAvatarValidator } from '../../middlewares/validators/avatar' @@ -34,6 +34,7 @@ import { JobQueue } from '../../lib/job-queue' import { VideoPlaylistModel } from '../../models/video/video-playlist' import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' import { CONFIG } from '../../initializers/config' +import { sequelizeTypescript } from '../../initializers/database' const auditLogger = auditLoggerFactory('channels') const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 5a3d6a29d..71c244a60 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts @@ -12,7 +12,7 @@ import { } from '../../middlewares' import { videoPlaylistsSortValidator } from '../../middlewares/validators' import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' -import { MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers' +import { MIMETYPES, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants' import { logger } from '../../helpers/logger' import { resetSequelizeInstance } from '../../helpers/database-utils' import { VideoPlaylistModel } from '../../models/video/video-playlist' @@ -42,6 +42,7 @@ import { AccountModel } from '../../models/account/account' import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' import { JobQueue } from '../../lib/job-queue' import { CONFIG } from '../../initializers/config' +import { sequelizeTypescript } from '../../initializers/database' const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts index 7dd36e368..44c255232 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/controllers/api/videos/captions.ts @@ -2,13 +2,14 @@ import * as express from 'express' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' import { createReqFiles } from '../../../helpers/express-utils' -import { MIMETYPES, sequelizeTypescript } from '../../../initializers' +import { MIMETYPES } from '../../../initializers/constants' import { getFormattedObjects } from '../../../helpers/utils' import { VideoCaptionModel } from '../../../models/video/video-caption' import { logger } from '../../../helpers/logger' import { federateVideoIfNeeded } from '../../../lib/activitypub' import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const reqVideoCaptionAdd = createReqFiles( [ 'captionfile' ], diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 5a8cd703e..a72b8c72e 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts @@ -3,7 +3,7 @@ import * as magnetUtil from 'magnet-uri' import 'multer' import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' -import { MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers' +import { MIMETYPES, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../../../initializers/constants' import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' import { createReqFiles } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' @@ -25,6 +25,7 @@ import { getSecureTorrentName } from '../../../helpers/utils' import { move, readFile } from 'fs-extra' import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const auditLogger = auditLoggerFactory('video-imports') const videoImportsRouter = express.Router() diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 9470afabf..d6f513254 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -10,13 +10,12 @@ import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' import { MIMETYPES, PREVIEWS_SIZE, - sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES -} from '../../../initializers' +} from '../../../initializers/constants' import { changeVideoChannelShare, federateVideoIfNeeded, @@ -61,6 +60,7 @@ import { watchingRouter } from './watching' import { Notifier } from '../../../lib/notifier' import { sendView } from '../../../lib/activitypub/send/send-view' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' const auditLogger = auditLoggerFactory('videos') const videosRouter = express.Router() diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 914c596c3..b65babedf 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -1,11 +1,12 @@ import * as express from 'express' import { UserVideoRateUpdate } from '../../../../shared' import { logger } from '../../../helpers/logger' -import { sequelizeTypescript, VIDEO_RATE_TYPES } from '../../../initializers' +import { VIDEO_RATE_TYPES } from '../../../initializers/constants' import { getRateUrl, sendVideoRateChange } from '../../../lib/activitypub' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' import { AccountModel } from '../../../models/account/account' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' +import { sequelizeTypescript } from '../../../initializers/database' const rateVideoRouter = express.Router() diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts index 58ead4799..7e8e6eff6 100644 --- a/server/controllers/bots.ts +++ b/server/controllers/bots.ts @@ -1,6 +1,6 @@ import * as express from 'express' import { asyncMiddleware } from '../middlewares' -import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' import * as sitemapModule from 'sitemap' import { logger } from '../helpers/logger' import { VideoModel } from '../models/video/video' diff --git a/server/controllers/client.ts b/server/controllers/client.ts index ece2f460c..f51470b41 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts @@ -1,7 +1,7 @@ import * as express from 'express' import { join } from 'path' import { root } from '../helpers/core-utils' -import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers' +import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' import { asyncMiddleware, embedCSP } from '../middlewares' import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n' import { ClientHtml } from '../lib/client-html' diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index 24c41d946..5064097cd 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts @@ -1,6 +1,5 @@ import * as express from 'express' -import { FEEDS, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' -import { THUMBNAILS_SIZE } from '../initializers' +import { FEEDS, ROUTE_CACHE_LIFETIME, THUMBNAILS_SIZE, WEBSERVER } from '../initializers/constants' import { asyncMiddleware, commonVideosFiltersValidator, diff --git a/server/controllers/services.ts b/server/controllers/services.ts index 83b01b475..c1c53c3fc 100644 --- a/server/controllers/services.ts +++ b/server/controllers/services.ts @@ -1,8 +1,7 @@ import * as express from 'express' -import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER } from '../initializers' +import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER } from '../initializers/constants' import { asyncMiddleware, oembedValidator } from '../middlewares' import { accountNameWithHostGetValidator } from '../middlewares/validators' -import { CONFIG } from '../initializers/config' const servicesRouter = express.Router() diff --git a/server/controllers/static.ts b/server/controllers/static.ts index be5fcc8ed..f6bb88725 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -7,7 +7,7 @@ import { STATIC_MAX_AGE, STATIC_PATHS, WEBSERVER -} from '../initializers' +} from '../initializers/constants' import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' import { cacheRoute } from '../middlewares/cache' import { asyncMiddleware, videosGetValidator } from '../middlewares' 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' diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 3922d8515..a0609d7cd 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -341,7 +341,7 @@ const VIDEO_LICENCES = { 7: 'Public Domain Dedication' } -const VIDEO_LANGUAGES = buildLanguages() +let VIDEO_LANGUAGES: { [id: string]: string } = {} const VIDEO_PRIVACIES = { [ VideoPrivacy.PUBLIC ]: 'Public', @@ -684,6 +684,7 @@ export { VIDEO_VIEW_LIFETIME, CONTACT_FORM_LIFETIME, VIDEO_PLAYLIST_PRIVACIES, + loadLanguages, buildLanguages } @@ -732,6 +733,10 @@ function buildVideosExtname () { : [ '.mp4', '.ogv', '.webm' ] } +function loadLanguages () { + VIDEO_LANGUAGES = buildLanguages() +} + function buildLanguages () { const iso639 = require('iso-639-3') diff --git a/server/initializers/index.ts b/server/initializers/index.ts index fe9190a9c..0fc1a7363 100644 --- a/server/initializers/index.ts +++ b/server/initializers/index.ts @@ -1,5 +1,3 @@ -// Constants first, database in second! -export * from './constants' export * from './database' export * from './installer' export * from './migrator' diff --git a/server/initializers/migrations/0170-actor-follow-score.ts b/server/initializers/migrations/0170-actor-follow-score.ts index 2deabaf98..a12b35da9 100644 --- a/server/initializers/migrations/0170-actor-follow-score.ts +++ b/server/initializers/migrations/0170-actor-follow-score.ts @@ -1,5 +1,5 @@ import * as Sequelize from 'sequelize' -import { ACTOR_FOLLOW_SCORE } from '../index' +import { ACTOR_FOLLOW_SCORE } from '../constants' async function up (utils: { transaction: Sequelize.Transaction, diff --git a/server/initializers/migrations/0210-video-language.ts b/server/initializers/migrations/0210-video-language.ts index b7ec90905..ca95c7527 100644 --- a/server/initializers/migrations/0210-video-language.ts +++ b/server/initializers/migrations/0210-video-language.ts @@ -1,5 +1,5 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../index' +import { CONSTRAINTS_FIELDS } from '../constants' async function up (utils: { transaction: Sequelize.Transaction, diff --git a/server/initializers/migrations/0215-video-support-length.ts b/server/initializers/migrations/0215-video-support-length.ts index 994eda60d..ba395050f 100644 --- a/server/initializers/migrations/0215-video-support-length.ts +++ b/server/initializers/migrations/0215-video-support-length.ts @@ -1,5 +1,4 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../index' async function up (utils: { transaction: Sequelize.Transaction, diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index cfefc26ce..0db75906c 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts @@ -12,7 +12,7 @@ import { logger } from '../../helpers/logger' import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' import { doRequest, downloadImage } from '../../helpers/requests' import { getUrlFromWebfinger } from '../../helpers/webfinger' -import { AVATARS_SIZE, MIMETYPES, sequelizeTypescript, WEBSERVER } from '../../initializers' +import { AVATARS_SIZE, MIMETYPES, WEBSERVER } from '../../initializers/constants' import { AccountModel } from '../../models/account/account' import { ActorModel } from '../../models/activitypub/actor' import { AvatarModel } from '../../models/avatar/avatar' @@ -22,6 +22,7 @@ import { JobQueue } from '../job-queue' import { getServerActor } from '../../helpers/utils' import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' import { CONFIG } from '../../initializers/config' +import { sequelizeTypescript } from '../../initializers/database' // Set account keys, this could be long so process after the account creation and do not block the client function setAsyncActorKeys (actor: ActorModel) { diff --git a/server/lib/activitypub/audience.ts b/server/lib/activitypub/audience.ts index 10277eca7..771a01366 100644 --- a/server/lib/activitypub/audience.ts +++ b/server/lib/activitypub/audience.ts @@ -1,6 +1,6 @@ import { Transaction } from 'sequelize' import { ActivityAudience } from '../../../shared/models/activitypub' -import { ACTIVITY_PUB } from '../../initializers' +import { ACTIVITY_PUB } from '../../initializers/constants' import { ActorModel } from '../../models/activitypub/actor' import { VideoModel } from '../../models/video/video' import { VideoCommentModel } from '../../models/video/video-comment' diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts index 9f4ca98ba..ba5b67bee 100644 --- a/server/lib/activitypub/crawl.ts +++ b/server/lib/activitypub/crawl.ts @@ -1,4 +1,4 @@ -import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT } from '../../initializers' +import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT } from '../../initializers/constants' import { doRequest } from '../../helpers/requests' import { logger } from '../../helpers/logger' import * as Bluebird from 'bluebird' diff --git a/server/lib/activitypub/playlist.ts b/server/lib/activitypub/playlist.ts index a0d0e736e..f312409bc 100644 --- a/server/lib/activitypub/playlist.ts +++ b/server/lib/activitypub/playlist.ts @@ -1,6 +1,6 @@ import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' import { crawlCollectionPage } from './crawl' -import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers' +import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY, THUMBNAILS_SIZE } from '../../initializers/constants' import { AccountModel } from '../../models/account/account' import { isArray } from '../../helpers/custom-validators/misc' import { getOrCreateActorAndServerAndModel } from './actor' @@ -18,6 +18,7 @@ import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' import { ActivityIconObject } from '../../../shared/models/activitypub/objects' import { CONFIG } from '../../initializers/config' +import { sequelizeTypescript } from '../../initializers/database' function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: AccountModel, to: string[]) { const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPlaylistPrivacy.PUBLIC : VideoPlaylistPrivacy.UNLISTED diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index 3bece0ff7..7f38402b6 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts @@ -10,7 +10,7 @@ import * as Bluebird from 'bluebird' import { doRequest } from '../../helpers/requests' import { getOrCreateActorAndServerAndModel } from './actor' import { logger } from '../../helpers/logger' -import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers' +import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) { diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts index 01950a13b..bcb7a4ee2 100644 --- a/server/lib/activitypub/url.ts +++ b/server/lib/activitypub/url.ts @@ -1,4 +1,4 @@ -import { WEBSERVER } from '../../initializers' +import { WEBSERVER } from '../../initializers/constants' import { ActorModel } from '../../models/activitypub/actor' import { ActorFollowModel } from '../../models/activitypub/actor-follow' import { VideoModel } from '../../models/video/video' diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts index 3f9d8f0fc..18f44d50e 100644 --- a/server/lib/activitypub/video-comments.ts +++ b/server/lib/activitypub/video-comments.ts @@ -2,7 +2,7 @@ import { VideoCommentObject } from '../../../shared/models/activitypub/objects/v import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' import { logger } from '../../helpers/logger' import { doRequest } from '../../helpers/requests' -import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY } from '../../initializers' +import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' import { ActorModel } from '../../models/activitypub/actor' import { VideoModel } from '../../models/video/video' import { VideoCommentModel } from '../../models/video/video-comment' diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts index ad7d81df6..7809c58b8 100644 --- a/server/lib/activitypub/video-rates.ts +++ b/server/lib/activitypub/video-rates.ts @@ -7,7 +7,7 @@ import * as Bluebird from 'bluebird' import { getOrCreateActorAndServerAndModel } from './actor' import { AccountVideoRateModel } from '../../models/account/account-video-rate' import { logger } from '../../helpers/logger' -import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers' +import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' import { doRequest } from '../../helpers/requests' import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' import { ActorModel } from '../../models/activitypub/actor' diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 191f4817b..b9252e363 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts @@ -17,14 +17,7 @@ import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos import { resetSequelizeInstance, retryTransactionWrapper } from '../../helpers/database-utils' import { logger } from '../../helpers/logger' import { doRequest, downloadImage } from '../../helpers/requests' -import { - ACTIVITY_PUB, - MIMETYPES, - P2P_MEDIA_LOADER_PEER_VERSION, - REMOTE_SCHEME, - sequelizeTypescript, - THUMBNAILS_SIZE -} from '../../initializers' +import { ACTIVITY_PUB, MIMETYPES, P2P_MEDIA_LOADER_PEER_VERSION, REMOTE_SCHEME, THUMBNAILS_SIZE } from '../../initializers/constants' import { ActorModel } from '../../models/activitypub/actor' import { TagModel } from '../../models/video/tag' import { VideoModel } from '../../models/video/video' @@ -51,6 +44,7 @@ import { AccountVideoRateModel } from '../../models/account/account-video-rate' import { VideoShareModel } from '../../models/video/video-share' import { VideoCommentModel } from '../../models/video/video-comment' import { CONFIG } from '../../initializers/config' +import { sequelizeTypescript } from '../../initializers/database' async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { // If the video is not private and is published, we federate it diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts index a5316df4b..dca543d0b 100644 --- a/server/lib/avatar.ts +++ b/server/lib/avatar.ts @@ -1,6 +1,6 @@ import 'multer' import { sendUpdateActor } from './activitypub/send' -import { AVATARS_SIZE, sequelizeTypescript } from '../initializers' +import { AVATARS_SIZE } from '../initializers/constants' import { updateActorAvatarInstance } from './activitypub' import { processImage } from '../helpers/image-utils' import { AccountModel } from '../models/account/account' @@ -9,6 +9,7 @@ import { extname, join } from 'path' import { retryTransactionWrapper } from '../helpers/database-utils' import * as uuidv4 from 'uuid/v4' import { CONFIG } from '../initializers/config' +import { sequelizeTypescript } from '../initializers/database' async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) { const extension = extname(avatarPhysicalFile.filename) diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index f8e1e456f..516827a05 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts @@ -1,6 +1,6 @@ import * as express from 'express' import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' -import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, WEBSERVER } from '../initializers' +import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, WEBSERVER } from '../initializers/constants' import { join } from 'path' import { escapeHTML } from '../helpers/core-utils' import { VideoModel } from '../models/video/video' diff --git a/server/lib/files-cache/actor-follow-score-cache.ts b/server/lib/files-cache/actor-follow-score-cache.ts index d070bde09..5f8ee806f 100644 --- a/server/lib/files-cache/actor-follow-score-cache.ts +++ b/server/lib/files-cache/actor-follow-score-cache.ts @@ -1,4 +1,4 @@ -import { ACTOR_FOLLOW_SCORE } from '../../initializers' +import { ACTOR_FOLLOW_SCORE } from '../../initializers/constants' import { logger } from '../../helpers/logger' // Cache follows scores, instead of writing them too often in database diff --git a/server/lib/files-cache/videos-caption-cache.ts b/server/lib/files-cache/videos-caption-cache.ts index f5ccfe0a2..0926f4009 100644 --- a/server/lib/files-cache/videos-caption-cache.ts +++ b/server/lib/files-cache/videos-caption-cache.ts @@ -1,5 +1,5 @@ import { join } from 'path' -import { FILES_CACHE } from '../../initializers' +import { FILES_CACHE } from '../../initializers/constants' import { VideoModel } from '../../models/video/video' import { VideoCaptionModel } from '../../models/video/video-caption' import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' diff --git a/server/lib/files-cache/videos-preview-cache.ts b/server/lib/files-cache/videos-preview-cache.ts index 192f99aec..6575e1c83 100644 --- a/server/lib/files-cache/videos-preview-cache.ts +++ b/server/lib/files-cache/videos-preview-cache.ts @@ -1,5 +1,5 @@ import { join } from 'path' -import { FILES_CACHE, STATIC_PATHS } from '../../initializers' +import { FILES_CACHE, STATIC_PATHS } from '../../initializers/constants' import { VideoModel } from '../../models/video/video' import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' import { CONFIG } from '../../initializers/config' diff --git a/server/lib/hls.ts b/server/lib/hls.ts index e804e7b3a..98da4dcd8 100644 --- a/server/lib/hls.ts +++ b/server/lib/hls.ts @@ -1,6 +1,6 @@ import { VideoModel } from '../models/video/video' import { basename, dirname, join } from 'path' -import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers' +import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION } from '../initializers/constants' import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' import { getVideoFileSize } from '../helpers/ffmpeg-utils' import { sha256 } from '../helpers/core-utils' @@ -11,6 +11,7 @@ import { generateRandomString } from '../helpers/utils' import { flatten, uniq } from 'lodash' import { VideoFileModel } from '../models/video/video-file' import { CONFIG } from '../initializers/config' +import { sequelizeTypescript } from '../initializers/database' async function updateStreamingPlaylistsInfohashesIfNeeded () { const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion() diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index 7c84aa937..b3defb617 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts @@ -1,6 +1,6 @@ import * as Bull from 'bull' import { logger } from '../../../helpers/logger' -import { REMOTE_SCHEME, sequelizeTypescript, WEBSERVER } from '../../../initializers' +import { REMOTE_SCHEME, WEBSERVER } from '../../../initializers/constants' import { sendFollow } from '../../activitypub/send' import { sanitizeHost } from '../../../helpers/core-utils' import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' @@ -9,6 +9,7 @@ import { retryTransactionWrapper } from '../../../helpers/database-utils' import { ActorFollowModel } from '../../../models/activitypub/actor-follow' import { ActorModel } from '../../../models/activitypub/actor' import { Notifier } from '../../notifier' +import { sequelizeTypescript } from '../../../initializers/database' export type ActivitypubFollowPayload = { followerActorId: number diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts index 2b1e21c39..0ff7b44a0 100644 --- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts @@ -3,7 +3,7 @@ import * as Bluebird from 'bluebird' import { logger } from '../../../helpers/logger' import { doRequest } from '../../../helpers/requests' import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' -import { BROADCAST_CONCURRENCY, JOB_REQUEST_TIMEOUT } from '../../../initializers' +import { BROADCAST_CONCURRENCY, JOB_REQUEST_TIMEOUT } from '../../../initializers/constants' import { ActorFollowScoreCache } from '../../files-cache' export type ActivitypubHttpBroadcastPayload = { diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/lib/job-queue/handlers/activitypub-http-unicast.ts index 59de7119a..c70ce3be9 100644 --- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-unicast.ts @@ -2,7 +2,7 @@ import * as Bull from 'bull' import { logger } from '../../../helpers/logger' import { doRequest } from '../../../helpers/requests' import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' -import { JOB_REQUEST_TIMEOUT } from '../../../initializers' +import { JOB_REQUEST_TIMEOUT } from '../../../initializers/constants' import { ActorFollowScoreCache } from '../../files-cache' export type ActivitypubHttpUnicastPayload = { diff --git a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts index 4961d4502..5c25625f6 100644 --- a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts +++ b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts @@ -2,7 +2,7 @@ import { buildSignedActivity } from '../../../../helpers/activitypub' import { getServerActor } from '../../../../helpers/utils' import { ActorModel } from '../../../../models/activitypub/actor' import { sha256 } from '../../../../helpers/core-utils' -import { HTTP_SIGNATURE } from '../../../../initializers' +import { HTTP_SIGNATURE } from '../../../../initializers/constants' type Payload = { body: any, signatureActorId?: number } diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 732773efd..8e8aa1597 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts @@ -6,7 +6,7 @@ import { VideoImportState } from '../../../../shared/models/videos' import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' import { extname, join } from 'path' import { VideoFileModel } from '../../../models/video/video-file' -import { PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' +import { PREVIEWS_SIZE, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers/constants' import { downloadImage } from '../../../helpers/requests' import { VideoState } from '../../../../shared' import { JobQueue } from '../index' @@ -17,6 +17,7 @@ import { getSecureTorrentName } from '../../../helpers/utils' import { move, remove, stat } from 'fs-extra' import { Notifier } from '../../notifier' import { CONFIG } from '../../../initializers/config' +import { sequelizeTypescript } from '../../../initializers/database' type VideoImportYoutubeDLPayload = { type: 'youtube-dl' diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index 1c2aa109d..f09eb6ff1 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts @@ -2,7 +2,7 @@ import * as Bull from 'bull' import { JobState, JobType } from '../../../shared/models' import { logger } from '../../helpers/logger' import { Redis } from '../redis' -import { JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers' +import { JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers/constants' import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' diff --git a/server/lib/redis.ts b/server/lib/redis.ts index a7ec8c9df..b4044bf0f 100644 --- a/server/lib/redis.ts +++ b/server/lib/redis.ts @@ -8,7 +8,7 @@ import { USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME, WEBSERVER -} from '../initializers' +} from '../initializers/constants' import { CONFIG } from '../initializers/config' type CachedRoute = { diff --git a/server/lib/schedulers/actor-follow-scheduler.ts b/server/lib/schedulers/actor-follow-scheduler.ts index 05e6bd139..fdd3ad5fa 100644 --- a/server/lib/schedulers/actor-follow-scheduler.ts +++ b/server/lib/schedulers/actor-follow-scheduler.ts @@ -2,7 +2,7 @@ import { isTestInstance } from '../../helpers/core-utils' import { logger } from '../../helpers/logger' import { ActorFollowModel } from '../../models/activitypub/actor-follow' import { AbstractScheduler } from './abstract-scheduler' -import { SCHEDULER_INTERVALS_MS } from '../../initializers' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' import { ActorFollowScoreCache } from '../files-cache' export class ActorFollowScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/remove-old-jobs-scheduler.ts b/server/lib/schedulers/remove-old-jobs-scheduler.ts index 4a4341ba9..0179a7618 100644 --- a/server/lib/schedulers/remove-old-jobs-scheduler.ts +++ b/server/lib/schedulers/remove-old-jobs-scheduler.ts @@ -2,7 +2,7 @@ import { isTestInstance } from '../../helpers/core-utils' import { logger } from '../../helpers/logger' import { JobQueue } from '../job-queue' import { AbstractScheduler } from './abstract-scheduler' -import { SCHEDULER_INTERVALS_MS } from '../../initializers' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' export class RemoveOldJobsScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/update-videos-scheduler.ts b/server/lib/schedulers/update-videos-scheduler.ts index 2179a2f26..80080a132 100644 --- a/server/lib/schedulers/update-videos-scheduler.ts +++ b/server/lib/schedulers/update-videos-scheduler.ts @@ -3,10 +3,11 @@ import { AbstractScheduler } from './abstract-scheduler' import { ScheduleVideoUpdateModel } from '../../models/video/schedule-video-update' import { retryTransactionWrapper } from '../../helpers/database-utils' import { federateVideoIfNeeded } from '../activitypub' -import { SCHEDULER_INTERVALS_MS, sequelizeTypescript } from '../../initializers' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' import { VideoPrivacy } from '../../../shared/models/videos' import { Notifier } from '../notifier' import { VideoModel } from '../../models/video/video' +import { sequelizeTypescript } from '../../initializers/database' export class UpdateVideosScheduler extends AbstractScheduler { diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 4a8a1d413..01af1e9d2 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts @@ -1,5 +1,5 @@ import { AbstractScheduler } from './abstract-scheduler' -import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT, WEBSERVER } from '../../initializers' +import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT, WEBSERVER } from '../../initializers/constants' import { logger } from '../../helpers/logger' import { VideosRedundancy } from '../../../shared/models/redundancy' import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' diff --git a/server/lib/schedulers/youtube-dl-update-scheduler.ts b/server/lib/schedulers/youtube-dl-update-scheduler.ts index aa027116d..aefe6aba4 100644 --- a/server/lib/schedulers/youtube-dl-update-scheduler.ts +++ b/server/lib/schedulers/youtube-dl-update-scheduler.ts @@ -1,5 +1,5 @@ import { AbstractScheduler } from './abstract-scheduler' -import { SCHEDULER_INTERVALS_MS } from '../../initializers' +import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' import { updateYoutubeDLBinary } from '../../helpers/youtube-dl' export class YoutubeDlUpdateScheduler extends AbstractScheduler { diff --git a/server/lib/user.ts b/server/lib/user.ts index 6fbe3ed03..ce0d60518 100644 --- a/server/lib/user.ts +++ b/server/lib/user.ts @@ -1,7 +1,7 @@ import * as Sequelize from 'sequelize' import * as uuidv4 from 'uuid/v4' import { ActivityPubActorType } from '../../shared/models/activitypub' -import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../initializers' +import { SERVER_ACTOR_NAME } from '../initializers/constants' import { AccountModel } from '../models/account/account' import { UserModel } from '../models/account/user' import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub' @@ -12,6 +12,7 @@ import { ActorModel } from '../models/activitypub/actor' import { UserNotificationSettingModel } from '../models/account/user-notification-setting' import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users' import { createWatchLaterPlaylist } from './video-playlist' +import { sequelizeTypescript } from '../initializers/database' async function createUserAccountAndChannelAndPlaylist (userToCreate: UserModel, validateUser = true) { const { user, account, videoChannel } = await sequelizeTypescript.transaction(async t => { diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 11098dca3..0fe0ff12a 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts @@ -1,4 +1,4 @@ -import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers' +import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants' import { join } from 'path' import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' import { ensureDir, move, remove, stat } from 'fs-extra' diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index c528ee250..88cf342ee 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts @@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from 'express' import { ActivityPubSignature } from '../../shared' import { logger } from '../helpers/logger' import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' -import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers' +import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' import { getOrCreateActorAndServerAndModel } from '../lib/activitypub' import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger' diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index 1d193d467..de736e593 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts @@ -1,7 +1,7 @@ import * as express from 'express' import * as OAuthServer from 'express-oauth-server' import 'express-validator' -import { OAUTH_LIFETIME } from '../initializers' +import { OAUTH_LIFETIME } from '../initializers/constants' import { logger } from '../helpers/logger' import { Socket } from 'socket.io' import { getAccessToken } from '../lib/oauth-model' diff --git a/server/middlewares/pagination.ts b/server/middlewares/pagination.ts index 9b497b19e..83304940f 100644 --- a/server/middlewares/pagination.ts +++ b/server/middlewares/pagination.ts @@ -1,7 +1,7 @@ import 'express-validator' import * as express from 'express' -import { PAGINATION } from '../initializers' +import { PAGINATION } from '../initializers/constants' function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) { if (!req.query.start) req.query.start = 0 diff --git a/server/middlewares/validators/avatar.ts b/server/middlewares/validators/avatar.ts index ddc14f531..bab3ed118 100644 --- a/server/middlewares/validators/avatar.ts +++ b/server/middlewares/validators/avatar.ts @@ -2,7 +2,7 @@ import * as express from 'express' import { body } from 'express-validator/check' import { isAvatarFile } from '../../helpers/custom-validators/users' import { areValidationErrors } from './utils' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { logger } from '../../helpers/logger' import { cleanUpReqFiles } from '../../helpers/express-utils' diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts index 5623b4ba6..2e5a02307 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/middlewares/validators/follows.ts @@ -4,7 +4,7 @@ import { isTestInstance } from '../../helpers/core-utils' import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' import { logger } from '../../helpers/logger' import { getServerActor } from '../../helpers/utils' -import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers' +import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' import { ActorFollowModel } from '../../models/activitypub/actor-follow' import { areValidationErrors } from './utils' import { ActorModel } from '../../models/activitypub/actor' diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts index 44295c325..b497798d1 100644 --- a/server/middlewares/validators/sort.ts +++ b/server/middlewares/validators/sort.ts @@ -1,4 +1,4 @@ -import { SORTABLE_COLUMNS } from '../../initializers' +import { SORTABLE_COLUMNS } from '../../initializers/constants' import { checkSort, createSortableColumns } from './utils' // Initialize constants here for better performances diff --git a/server/middlewares/validators/videos/video-captions.ts b/server/middlewares/validators/videos/video-captions.ts index b2b259aff..d857ac3ec 100644 --- a/server/middlewares/validators/videos/video-captions.ts +++ b/server/middlewares/validators/videos/video-captions.ts @@ -3,7 +3,7 @@ import { areValidationErrors } from '../utils' 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 { CONSTRAINTS_FIELDS } from '../../../initializers/constants' import { UserRight } from '../../../../shared' import { logger } from '../../../helpers/logger' import { doesVideoCaptionExist, isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions' diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts index e2067c4d9..4b26f0bc4 100644 --- a/server/middlewares/validators/videos/video-channels.ts +++ b/server/middlewares/validators/videos/video-channels.ts @@ -1,12 +1,11 @@ import * as express from 'express' import { body, param } from 'express-validator/check' import { UserRight } from '../../../../shared' -import { doesAccountNameWithHostExist } from '../../../helpers/custom-validators/accounts' import { doesLocalVideoChannelNameExist, + doesVideoChannelNameWithHostExist, isVideoChannelDescriptionValid, isVideoChannelNameValid, - doesVideoChannelNameWithHostExist, isVideoChannelSupportValid } from '../../../helpers/custom-validators/video-channels' import { logger } from '../../../helpers/logger' diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts index fb13f3ceb..452084a7c 100644 --- a/server/middlewares/validators/videos/video-imports.ts +++ b/server/middlewares/validators/videos/video-imports.ts @@ -8,7 +8,7 @@ import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../ import { cleanUpReqFiles } from '../../../helpers/express-utils' import { doesVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos' import { CONFIG } from '../../../initializers/config' -import { CONSTRAINTS_FIELDS } from '../../../initializers' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' const videoImportAddValidator = getCommonVideoEditAttributes().concat([ body('channelId') diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts index 6ba30fac9..2c3f7e542 100644 --- a/server/middlewares/validators/videos/video-playlists.ts +++ b/server/middlewares/validators/videos/video-playlists.ts @@ -5,7 +5,7 @@ import { logger } from '../../../helpers/logger' import { UserModel } from '../../../models/account/user' import { areValidationErrors } from '../utils' import { doesVideoExist, isVideoImage } from '../../../helpers/custom-validators/videos' -import { CONSTRAINTS_FIELDS } from '../../../initializers' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' import { isArrayOf, isIdOrUUIDValid, isIdValid, isUUIDValid, toIntArray, toValueOrNull } from '../../../helpers/custom-validators/misc' import { doesVideoPlaylistExist, diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 7ce1a922f..e9b036a02 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -32,7 +32,7 @@ import { } from '../../../helpers/custom-validators/videos' import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils' import { logger } from '../../../helpers/logger' -import { CONSTRAINTS_FIELDS } from '../../../initializers' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' import { authenticatePromiseIfNeeded } from '../../oauth' import { areValidationErrors } from '../utils' import { cleanUpReqFiles } from '../../../helpers/express-utils' diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index f462df4b3..78a897a65 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts @@ -3,7 +3,7 @@ import { Transaction, Op } from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' import { IFindOptions } from 'sequelize-typescript/lib/interfaces/IFindOptions' import { VideoRateType } from '../../../shared/models/videos' -import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers' +import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants' import { VideoModel } from '../video/video' import { AccountModel } from './account' import { ActorModel } from '../activitypub/actor' diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 8aff9f497..38585c016 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -42,7 +42,7 @@ import { VideoChannelModel } from '../video/video-channel' import { AccountModel } from './account' import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' import { values } from 'lodash' -import { NSFW_POLICY_TYPES } from '../../initializers' +import { NSFW_POLICY_TYPES } from '../../initializers/constants' import { clearCacheByUserId } from '../../lib/oauth-model' import { UserNotificationSettingModel } from './user-notification-setting' import { VideoModel } from '../video/video' diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index e3eeb7dae..1b272e1c8 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts @@ -22,7 +22,7 @@ import { FollowState } from '../../../shared/models/actors' import { ActorFollow } from '../../../shared/models/actors/follow.model' import { logger } from '../../helpers/logger' import { getServerActor } from '../../helpers/utils' -import { ACTOR_FOLLOW_SCORE } from '../../initializers' +import { ACTOR_FOLLOW_SCORE } from '../../initializers/constants' import { FOLLOW_STATES } from '../../initializers/constants' import { ServerModel } from '../server/server' import { getSort } from '../utils' diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index 5472c8b92..e8f603031 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts @@ -30,7 +30,7 @@ import { isActorPublicKeyValid } from '../../helpers/custom-validators/activitypub/actor' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers' +import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' import { AccountModel } from '../account/account' import { AvatarModel } from '../avatar/avatar' import { ServerModel } from '../server/server' diff --git a/server/models/avatar/avatar.ts b/server/models/avatar/avatar.ts index 455835524..aaf1b8bd9 100644 --- a/server/models/avatar/avatar.ts +++ b/server/models/avatar/avatar.ts @@ -1,7 +1,7 @@ import { join } from 'path' import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' import { Avatar } from '../../../shared/models/avatars/avatar.model' -import { STATIC_PATHS } from '../../initializers' +import { STATIC_PATHS } from '../../initializers/constants' import { logger } from '../../helpers/logger' import { remove } from 'fs-extra' import { CONFIG } from '../../initializers/config' diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 39c50be5c..2b8e44223 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts @@ -15,7 +15,7 @@ import { import { ActorModel } from '../activitypub/actor' import { getVideoSort, throwIfNotValid } from '../utils' import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers' +import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers/constants' import { VideoFileModel } from '../video/video-file' import { getServerActor } from '../../helpers/utils' import { VideoModel } from '../video/video' diff --git a/server/models/utils.ts b/server/models/utils.ts index f8a71b270..a478bc62b 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts @@ -1,6 +1,5 @@ import { Sequelize } from 'sequelize-typescript' import * as validator from 'validator' -import { ACTIVITY_PUB } from '../initializers' type SortType = { sortModel: any, sortValue: string } diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts index cc47644f2..eacd651cc 100644 --- a/server/models/video/video-abuse.ts +++ b/server/models/video/video-abuse.ts @@ -10,7 +10,7 @@ import { AccountModel } from '../account/account' import { getSort, throwIfNotValid } from '../utils' import { VideoModel } from './video' import { VideoAbuseState } from '../../../shared' -import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers' +import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants' @Table({ tableName: 'videoAbuse', diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index 86b1f6acb..2619b4950 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts @@ -16,7 +16,7 @@ import { VideoModel } from './video' import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel' import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' @Table({ tableName: 'videoBlacklist', diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.ts index c670bce71..f2dbbfde8 100644 --- a/server/models/video/video-caption.ts +++ b/server/models/video/video-caption.ts @@ -16,7 +16,7 @@ import { throwIfNotValid } from '../utils' import { VideoModel } from './video' import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' -import { STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers' +import { STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers/constants' import { join } from 'path' import { logger } from '../../helpers/logger' import { remove } from 'fs-extra' diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 1abc23eaa..5b5075344 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -29,7 +29,7 @@ import { AccountModel, ScopeNames as AccountModelScopeNames } from '../account/a import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' import { VideoModel } from './video' -import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers' +import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' import { ServerModel } from '../server/server' import { DefineIndexesOptions } from 'sequelize' import { AvatarModel } from '../avatar/avatar' diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 47f1cbb99..cb5f1cbbe 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts @@ -18,7 +18,7 @@ import { ActivityTagObject } from '../../../shared/models/activitypub/objects/co import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object' import { VideoComment } from '../../../shared/models/videos/video-comment.model' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers' +import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' import { sendDeleteVideoComment } from '../../lib/activitypub/send' import { AccountModel } from '../account/account' import { ActorModel } from '../activitypub/actor' diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index 7915fc1f9..64771b1ff 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts @@ -7,7 +7,7 @@ import { ActivityUrlObject, VideoTorrentObject } from '../../../shared/models/activitypub/objects' -import { MIMETYPES, THUMBNAILS_SIZE, WEBSERVER } from '../../initializers' +import { MIMETYPES, THUMBNAILS_SIZE, WEBSERVER } from '../../initializers/constants' import { VideoCaptionModel } from './video-caption' import { getVideoCommentsActivityPubUrl, diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts index 9bc0f17f5..ec10085d6 100644 --- a/server/models/video/video-import.ts +++ b/server/models/video/video-import.ts @@ -13,7 +13,7 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers' +import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers/constants' import { getSort, throwIfNotValid } from '../utils' import { ScopeNames as VideoModelScopeNames, VideoModel } from './video' import { isVideoImportStateValid, isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports' diff --git a/server/models/video/video-playlist-element.ts b/server/models/video/video-playlist-element.ts index a2bd225a1..3396b1136 100644 --- a/server/models/video/video-playlist-element.ts +++ b/server/models/video/video-playlist-element.ts @@ -18,7 +18,7 @@ import { VideoPlaylistModel } from './video-playlist' import * as Sequelize from 'sequelize' import { getSort, throwIfNotValid } from '../utils' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { PlaylistElementObject } from '../../../shared/models/activitypub/objects/playlist-element-object' import * as validator from 'validator' diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index 93f36a9d0..0725b752a 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts @@ -32,7 +32,7 @@ import { VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES, WEBSERVER -} from '../../initializers' +} from '../../initializers/constants' import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model' import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account' import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel' diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index 399081564..c83f6c5b0 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts @@ -2,7 +2,7 @@ import * as Sequelize from 'sequelize' import * as Bluebird from 'bluebird' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { AccountModel } from '../account/account' import { ActorModel } from '../activitypub/actor' import { throwIfNotValid } from '../utils' diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index 0333755c5..e50b5d106 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts @@ -6,7 +6,7 @@ import * as Sequelize from 'sequelize' import { VideoRedundancyModel } from '../redundancy/video-redundancy' import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { CONSTRAINTS_FIELDS, STATIC_PATHS, P2P_MEDIA_LOADER_PEER_VERSION } from '../../initializers' +import { CONSTRAINTS_FIELDS, STATIC_PATHS, P2P_MEDIA_LOADER_PEER_VERSION } from '../../initializers/constants' import { VideoFileModel } from './video-file' import { join } from 'path' import { sha1 } from '../../helpers/core-utils' diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 3b30e9e28..38447797e 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -65,7 +65,7 @@ import { VIDEO_PRIVACIES, VIDEO_STATES, WEBSERVER -} from '../../initializers' +} from '../../initializers/constants' import { sendDeleteVideo } from '../../lib/activitypub/send' import { AccountModel } from '../account/account' import { AccountVideoRateModel } from '../account/account-video-rate' diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index b78504073..a92326846 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts @@ -12,7 +12,7 @@ import { ServerInfo, setActorField } from '../../../../shared/utils' -import { HTTP_SIGNATURE } from '../../../initializers' +import { HTTP_SIGNATURE } from '../../../initializers/constants' import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils' import * as chai from 'chai' import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub' diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index 6f6bc25a6..f84ba1ece 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -18,7 +18,7 @@ import { } from '../../../shared/utils' import { waitJobs } from '../../../shared/utils/server/jobs' import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffmpeg-utils' -import { VIDEO_TRANSCODING_FPS } from '../../initializers' +import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' import { join } from 'path' const expect = chai.expect diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 04e24e818..03f13b5e2 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -5,7 +5,7 @@ import * as program from 'commander' import { join } from 'path' import { VideoPrivacy } from '../../shared/models/videos' import { doRequestAndSaveToFile } from '../helpers/requests' -import { CONSTRAINTS_FIELDS } from '../initializers' +import { CONSTRAINTS_FIELDS } from '../initializers/constants' import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo } from '../../shared/utils/index' import { truncate } from 'lodash' import * as prompt from 'prompt' diff --git a/shared/utils/requests/activitypub.ts b/shared/utils/requests/activitypub.ts index e2348ace0..4762a8665 100644 --- a/shared/utils/requests/activitypub.ts +++ b/shared/utils/requests/activitypub.ts @@ -1,5 +1,5 @@ import { doRequest } from '../../../server/helpers/requests' -import { HTTP_SIGNATURE } from '../../../server/initializers' +import { HTTP_SIGNATURE } from '../../../server/initializers/constants' import { buildGlobalHeaders } from '../../../server/lib/job-queue/handlers/utils/activitypub-http-utils' import { activityPubContextify } from '../../../server/helpers/activitypub' -- 2.25.1