Don't expose constants directly in initializers/
authorChocobozzz <me@florianbigard.com>
Thu, 11 Apr 2019 12:26:41 +0000 (14:26 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 11 Apr 2019 12:26:41 +0000 (14:26 +0200)
114 files changed:
scripts/danger/clean/cleaner.ts
scripts/optimize-old-videos.ts
scripts/parse-log.ts
scripts/prune-storage.ts
scripts/update-host.ts
server.ts
server/controllers/activitypub/client.ts
server/controllers/api/config.ts
server/controllers/api/overviews.ts
server/controllers/api/server/follows.ts
server/controllers/api/server/logs.ts
server/controllers/api/users/index.ts
server/controllers/api/users/me.ts
server/controllers/api/users/my-subscriptions.ts
server/controllers/api/video-channel.ts
server/controllers/api/video-playlist.ts
server/controllers/api/videos/captions.ts
server/controllers/api/videos/import.ts
server/controllers/api/videos/index.ts
server/controllers/api/videos/rate.ts
server/controllers/bots.ts
server/controllers/client.ts
server/controllers/feeds.ts
server/controllers/services.ts
server/controllers/static.ts
server/helpers/activitypub.ts
server/helpers/core-utils.ts
server/helpers/custom-validators/activitypub/actor.ts
server/helpers/custom-validators/activitypub/misc.ts
server/helpers/custom-validators/activitypub/video-comments.ts
server/helpers/custom-validators/activitypub/videos.ts
server/helpers/custom-validators/servers.ts
server/helpers/custom-validators/users.ts
server/helpers/custom-validators/video-abuses.ts
server/helpers/custom-validators/video-blacklist.ts
server/helpers/custom-validators/video-captions.ts
server/helpers/custom-validators/video-channels.ts
server/helpers/custom-validators/video-comments.ts
server/helpers/custom-validators/video-imports.ts
server/helpers/custom-validators/video-playlists.ts
server/helpers/custom-validators/videos.ts
server/helpers/custom-validators/webfinger.ts
server/helpers/express-utils.ts
server/helpers/peertube-crypto.ts
server/helpers/requests.ts
server/helpers/youtube-dl.ts
server/initializers/constants.ts
server/initializers/index.ts
server/initializers/migrations/0170-actor-follow-score.ts
server/initializers/migrations/0210-video-language.ts
server/initializers/migrations/0215-video-support-length.ts
server/lib/activitypub/actor.ts
server/lib/activitypub/audience.ts
server/lib/activitypub/crawl.ts
server/lib/activitypub/playlist.ts
server/lib/activitypub/share.ts
server/lib/activitypub/url.ts
server/lib/activitypub/video-comments.ts
server/lib/activitypub/video-rates.ts
server/lib/activitypub/videos.ts
server/lib/avatar.ts
server/lib/client-html.ts
server/lib/files-cache/actor-follow-score-cache.ts
server/lib/files-cache/videos-caption-cache.ts
server/lib/files-cache/videos-preview-cache.ts
server/lib/hls.ts
server/lib/job-queue/handlers/activitypub-follow.ts
server/lib/job-queue/handlers/activitypub-http-broadcast.ts
server/lib/job-queue/handlers/activitypub-http-unicast.ts
server/lib/job-queue/handlers/utils/activitypub-http-utils.ts
server/lib/job-queue/handlers/video-import.ts
server/lib/job-queue/job-queue.ts
server/lib/redis.ts
server/lib/schedulers/actor-follow-scheduler.ts
server/lib/schedulers/remove-old-jobs-scheduler.ts
server/lib/schedulers/update-videos-scheduler.ts
server/lib/schedulers/videos-redundancy-scheduler.ts
server/lib/schedulers/youtube-dl-update-scheduler.ts
server/lib/user.ts
server/lib/video-transcoding.ts
server/middlewares/activitypub.ts
server/middlewares/oauth.ts
server/middlewares/pagination.ts
server/middlewares/validators/avatar.ts
server/middlewares/validators/follows.ts
server/middlewares/validators/sort.ts
server/middlewares/validators/videos/video-captions.ts
server/middlewares/validators/videos/video-channels.ts
server/middlewares/validators/videos/video-imports.ts
server/middlewares/validators/videos/video-playlists.ts
server/middlewares/validators/videos/videos.ts
server/models/account/account-video-rate.ts
server/models/account/user.ts
server/models/activitypub/actor-follow.ts
server/models/activitypub/actor.ts
server/models/avatar/avatar.ts
server/models/redundancy/video-redundancy.ts
server/models/utils.ts
server/models/video/video-abuse.ts
server/models/video/video-blacklist.ts
server/models/video/video-caption.ts
server/models/video/video-channel.ts
server/models/video/video-comment.ts
server/models/video/video-format-utils.ts
server/models/video/video-import.ts
server/models/video/video-playlist-element.ts
server/models/video/video-playlist.ts
server/models/video/video-share.ts
server/models/video/video-streaming-playlist.ts
server/models/video/video.ts
server/tests/api/activitypub/security.ts
server/tests/cli/optimize-old-videos.ts
server/tools/peertube-import-videos.ts
shared/utils/requests/activitypub.ts

index 009f8f7a0c95d93816fed572c887b3b3c079ec27..d575af283211dd1df8d22f7ccab5e720f3e2ff48 100644 (file)
@@ -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(() => {
index 1bee1b0f3ba4e8f149789e348bdd7a9fde7804af..a1d5345a1164a668ccaded484c407faf9dfdbc25 100644 (file)
@@ -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))
index 66a5b87198fa990005d865b8e7b3edf7833de6d0..fe87db009b685324720a820e5cf884139686d264 100755 (executable)
@@ -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
index c9e4dbd4b8094bead529388148c9ab0dda73a0a1..4953a74399eb47a7239646bc5fee59b798149cca 100755 (executable)
@@ -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'
index 64eba867a4bae8769c32a4b5758f54c2288b86c3..57919b9981a4f40bf27b48bb541d1738466aa0e1 100755 (executable)
@@ -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()
     }
index dfaa8ad3df7a2575e9947a7abc22bc8b8ef62a61..110ae1ab8e3e0d98f6a9799ffbd5673075a40886 100644 (file)
--- 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', () => {
index f47fae76610ad40ae09e5c486071fdbdd22b2187..d36d10de1b3d33bc63bec0bc25e12bf2f57be458 100644 (file)
@@ -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'
index cdbccaa7dee4d0f8e4caa72f92b14332e0699791..40012c03bef334295639542e9b14e734e4ede1f6 100644 (file)
@@ -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'
index b052acdb7485282c37d97fa4a9f87dcb6c326b0e..37ac152dbe5ee2f47f28da27fc2fa86df3e07ce3 100644 (file)
@@ -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'
 
index 207a09a4cdfda1d5bb39ee42109af9ca3dc38932..d38ce91debdde0aa5979c8f1a1798447806db784 100644 (file)
@@ -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',
index bbbfa1d8069490eeafbd75c5dfb508cc5a284f1e..03941cca7709ac2c0b71d7184265b70b75714c4c 100644 (file)
@@ -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'
index a049e23e4182db18f60d1ad12b22965bc2bdb973..28c8de3031a51c43a3b070dc659d30e97639008b 100644 (file)
@@ -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')
 
index 1d1588eca0d943fc67e1ed72b708225bba9a536c..ce9e78463366d9f7e5543678b94a0d3486984bf9 100644 (file)
@@ -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')
 
index 59b906a8b16c55e24f8638b222a52b46b54793ee..c52df31544fbe546998cf142a205fdba3f8200e9 100644 (file)
@@ -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()
 
index b79ce9cecfbf967b98eebcbce26b4f3e86ebea1d..3d6dbfe701bf8b6774a11b3a3248c7b9ecb8f48c 100644 (file)
@@ -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 })
index 5a3d6a29d2b48d644f0b6d0b3adcb32776094288..71c244a6034abd0376b6bfd6d9589c497de1a022 100644 (file)
@@ -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 })
 
index 7dd36e36872a80138de3f5f11d1f015f8b50b184..44c255232bd83cd8d467139091d32c03c89672cd 100644 (file)
@@ -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' ],
index 5a8cd703ea021143db6679244c14ad28f4f67d28..a72b8c72e9e642f3f53cc8cf3e48c875a7b620dd 100644 (file)
@@ -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()
index 9470afabfede88282cae0a6a94f89fa9b18258b5..d6f513254f9375640f0a34c64ea47817de426a56 100644 (file)
@@ -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()
index 914c596c343e06d251618fe410bb5a6c43610a8b..b65babedf1ccfa3db5670a9f7cee12104465c773 100644 (file)
@@ -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()
 
index 58ead4799d4e5f4dd5f477c4070c82638dceaf0e..7e8e6eff6c0f31a4b164d0791e0371e6b57e1d41 100644 (file)
@@ -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'
index ece2f460cc210cbe3d1830ddac57c6eae7c620b4..f51470b419507b64abde1c51b10346e8fc678c5f 100644 (file)
@@ -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'
index 24c41d946cab111c54a75fcc6816c9ba18b19379..5064097cd7f929837f18477e9e88807394d5a372 100644 (file)
@@ -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,
index 83b01b4756eacb1047a6d06ace533b54ea8685c1..c1c53c3fc80466a72aad65ed53493e586d688a8c 100644 (file)
@@ -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()
 
index be5fcc8ede732aff6f66c3e8d7c0e6faec5bd3f8..f6bb88725956e5ec4b255978c367c1ef0de5bc76 100644 (file)
@@ -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'
index 0c303c3697547a999443e408f9bbc6261212fa15..951a25669d4e2efb3e079c0cf7f9a748f63b0921 100644 (file)
@@ -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'
index 3f737c1d6ef94c67fd542756d78bf374ce1cef7e..f6d90bfca3321e6aa67cb39ddd49565834c925ea 100644 (file)
@@ -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))
   }
 
index c05f60f140b82984df19593da14dcbb8856d0c9f..deb331abbb8efb304d1a443c98a6fe71ff3047f8 100644 (file)
@@ -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'
index f1762d11ca0dd074caa7d2e0b3bb2a8d4d88928e..f9445929b78bd54eb9e76953c49258aa7c427790 100644 (file)
@@ -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'
 
index 0415db21c27e7d5454ddfac568d59e87d7cc4736..26c8c4cc6b5712bbea4b3c0aeaa262fee5878c68 100644 (file)
@@ -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
index d943331512feb52b38fc82f04f7c123d4e89f322..3ba6b07440cb07a3f943e77361f1d0d3b46245c0 100644 (file)
@@ -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 {
index 18c80ec8fcd587f7ee6083c2cf9a53d66962a00c..5c8bf0d2d5d5183371da02b482eba098d8770d31 100644 (file)
@@ -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 = {
index 80652b4798eb566f2606da590e681f74c581abc7..70af5f1f078c3ce492425018871bae5b01de996e 100644 (file)
@@ -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'
 
index 71500fde5b91a29f100be304a32eedfd18325043..a61dcee1cd9ef8df9cc9809647d6b87d8d9d4001 100644 (file)
@@ -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'
 
index 465f58a9c02c088e57c28fb842b32e0c4ae14e96..3743f70233cb2507036efbc13adc50f1dbcbbaf4 100644 (file)
@@ -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'
 
index 8bd1390030bab4802697bf867da7f7260bc065c2..3b6569a8ae757f8ff71f341b214eaa5a496c73a0 100644 (file)
@@ -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'
index ca8d207cf39bb0d572a5fa524f76fdb9e53112d0..fd56b9a70354b099a9e86bfd5410e2e5015d5e91 100644 (file)
@@ -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'
 
index 2b3f6606348799e5590de04eb49357896330ea14..0707e2af2638ed5f645966e9f5317d4c25af1d7e 100644 (file)
@@ -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
 
index 14db9b534345ff4a577f98546c2c4c65b11d98de..f4235e2fa788e3877ba259228eb68d7dc30f5463 100644 (file)
@@ -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'
index c962c5532348c27f17203ed28f20b30ee0d7fa83..2fe426560350683eb17a76f874a81cd084955aa9 100644 (file)
@@ -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'
 
index dd9d62d24192e315bc9dbb3a68aa5590895e3abc..eb08ae4ad9fb2a07912f4ea1ff9406fe30d7f146 100644 (file)
@@ -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'
index b18e43fad4660c05bbd52ec580ea7f398b2148fd..dd914341e8364c8d5020953ad296c2757c2f2056 100644 (file)
@@ -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'
 
index 2b574ab8e90849f40b02f16bfa5730e38abd367e..e0a1d56a587759adad40cdec568594b2ee41900a 100644 (file)
@@ -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'
index ab9ec077ee3957806d6009207d5349fedb0209f6..9148df2ebdc01194a3f52fc5327f47147cb3ca92 100644 (file)
@@ -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'
index 02854b1648b6aa0d87866db102a03d1ab2b14f0d..60c94da81160d327df6fc9f3e02c829eef9b11fa 100644 (file)
@@ -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'
index c188739ffca84d4ab0febef40b0238e41485cb8b..b3079370f0bd71ccebb7fd28172b708f4b881bce 100644 (file)
@@ -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'
index 3922d85155d73b0491b72af238df074d89516e57..a0609d7cde4aa95d64f77fe7139308e94c59dc5c 100644 (file)
@@ -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')
 
index fe9190a9c6ea8809d94bbdca56dd7c6f0f0f7ed5..0fc1a7363f0b37994b18f8d1e5a70d231acee915 100644 (file)
@@ -1,5 +1,3 @@
-// Constants first, database in second!
-export * from './constants'
 export * from './database'
 export * from './installer'
 export * from './migrator'
index 2deabaf98b2e817287020ad23aabf47f51fa0a88..a12b35da9dde5e4677da8b0c2f243191479fd2b2 100644 (file)
@@ -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,
index b7ec90905ccbac951c539945eeecf2762da20c71..ca95c7527423470346c3a9eb2045998e82974dd1 100644 (file)
@@ -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,
index 994eda60d6a6e80296101921c3fa4803e61c107c..ba395050f6b9b77f7de2c6a28cef862d99e04e21 100644 (file)
@@ -1,5 +1,4 @@
 import * as Sequelize from 'sequelize'
-import { CONSTRAINTS_FIELDS } from '../index'
 
 async function up (utils: {
   transaction: Sequelize.Transaction,
index cfefc26ceaac0d3ffd58484022e757e9864c3bbe..0db75906cf1019c5a2be7fd3830bf45217072ed3 100644 (file)
@@ -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) {
index 10277eca7bae7c437254c1134a3d0f7f33f1ba31..771a01366dd91297aa3c3d2268bac6721bd2b6fa 100644 (file)
@@ -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'
index 9f4ca98bac28e494b8971535a2a7ecc415804f9f..ba5b67beeedb0bd795e4c686db43dc56de892c48 100644 (file)
@@ -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'
index a0d0e736ea9c58ecb46bc1cbe1e02cc06e97be98..f312409bc5d03b8af3cf724277772411a1b092d9 100644 (file)
@@ -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
index 3bece0ff72748f49d9889c82dfd803ced36d9da3..7f38402b666debaeedd7a519212571e6a7d8518a 100644 (file)
@@ -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) {
index 01950a13b660bf1a36197f4e21b49a25c4014762..bcb7a4ee2f59404715218ef30bc9066a23e1fd70 100644 (file)
@@ -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'
index 3f9d8f0fc4a4c85c46f3c84e8eb8f76180790aa3..18f44d50ecbee4bfb1aaca7efd61809a1a20a3a9 100644 (file)
@@ -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'
index ad7d81df6226246d13d5a52374f89fb6cdf64c81..7809c58b868869680e0e90fc51d20868246f1e7a 100644 (file)
@@ -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'
index 191f4817b30679ea1aad82525b41f8642185bbb0..b9252e3633d94d84dbe8e0c64b4de517c9b6a1d2 100644 (file)
@@ -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
index a5316df4bb27562a11eef21e55e3d2cccd88674c..dca543d0b9de6c7ed8c645f088a8bad9dc54c7f9 100644 (file)
@@ -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)
index f8e1e456f6d6335ed7251def6cccbcbff8356b03..516827a054f926ae0a77c22bf0bafe2491784470 100644 (file)
@@ -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'
index d070bde09fbdff1b15e27e1876e4488a759a7074..5f8ee806fbb2354f80473fb41de0bcbb15ff387c 100644 (file)
@@ -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
index f5ccfe0a2617ebb9b155e2796d03be981fc53ef2..0926f400952a37e6738191621de7d9224372de2c 100644 (file)
@@ -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'
index 192f99aec6997c2c66b213cea147f06c6d466cb8..6575e1c83a172b121f333bffb4a19bc98a8ba123 100644 (file)
@@ -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'
index e804e7b3a4045af93301e0086ee17d010818b477..98da4dcd8a80f80683f4111c1cc8fc68e1abd74f 100644 (file)
@@ -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()
index 7c84aa93718b3f15a73af6f1d475e12726c2dc67..b3defb6173f91fc26528a0a8a722a8daa9fc9c74 100644 (file)
@@ -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
index 2b1e21c3939c3518ceaef2d74fe101cf8fced4f2..0ff7b44a0af8f3df10b238ed00fcefafc2303b5e 100644 (file)
@@ -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 = {
index 59de7119ade7f0fd14a8f3c68b9cce999dac52ca..c70ce3be90fb80a346787391acc85b8cbb5d63a5 100644 (file)
@@ -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 = {
index 4961d4502e2a5b43ceb2ed7f6c6c2f49854ebf2e..5c25625f62befb94f77decf67939a2ea25560433 100644 (file)
@@ -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 }
 
index 732773efd55d182b211ee67230c9f5c7313e4e0e..8e8aa15970039aa3b01e60ea84c46036ad4d70df 100644 (file)
@@ -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'
index 1c2aa109d6e60fd485aced768953ef2635d41a1a..f09eb6ff11748ccb6ec04949734774fb3d5cd83f 100644 (file)
@@ -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'
index a7ec8c9df92f089e84b82365c9bfc0a7349c3428..b4044bf0f62c27c00fcaf26338080ddec5376481 100644 (file)
@@ -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 = {
index 05e6bd139e2e1fe28b3bdebb678294ff1eeff4b2..fdd3ad5faac91c2df8e6d0b730ef77777019e5d2 100644 (file)
@@ -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 {
index 4a4341ba981250938aa93bd84ce81314a617735f..0179a7618cfea522e45fdcfafe84e0ce24b6ad9d 100644 (file)
@@ -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 {
 
index 2179a2f2600680322d346978657455025ace5b85..80080a132e8b3da3cd391b6b3518882ed134c9da 100644 (file)
@@ -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 {
 
index 4a8a1d413ccf4a4ed1e963826e30797e7e8e5100..01af1e9d2a92020c54242c7bf37d55d2ab501040 100644 (file)
@@ -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'
index aa027116d7c93b18fd0573538fcd36c1f9db4402..aefe6aba4a1fd6086b42f6522b371a5ec0cbdfe1 100644 (file)
@@ -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 {
index 6fbe3ed03f0e8e0ca99be563564db5ab727f6b61..ce0d60518f67e253fcb50b6b4215809339c17dec 100644 (file)
@@ -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 => {
index 11098dca3758572253e51a1ad7d0a670f691d905..0fe0ff12a4c0aa2fb4f15caba7a547bcaaf33471 100644 (file)
@@ -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'
index c528ee250f06a321319adad4061900f627cbf5bf..88cf342ee41ec94531dff3b683138397b5290a1f 100644 (file)
@@ -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'
 
index 1d193d467455b675f5a4d4e117555ff56649b17b..de736e5931aa525d754c780c5b943296922a59b9 100644 (file)
@@ -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'
index 9b497b19e78dfe778a0cf8f2276e3beec49b027c..83304940f38af1bc386e045717375b1dab47af3d 100644 (file)
@@ -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
index ddc14f53165b4d4dd045e25d7a1d94522ea06213..bab3ed118cd6858d48e16e58842618766ac4e4c9 100644 (file)
@@ -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'
 
index 5623b4ba65cecb7d33d318048474b18df6c8785d..2e5a02307743d16ef3bef12dfadf48f7e4377b1b 100644 (file)
@@ -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'
index 44295c3251868f597fc32fb14bf1f84d9508ac5e..b497798d129c1e782567213c93dcb3a9b22bf5e0 100644 (file)
@@ -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
index b2b259aff4c381c50d091331a46c8a55a7a11c9c..d857ac3ec021aef98f7c1a2ae094fd956c4ef4c6 100644 (file)
@@ -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'
index e2067c4d99f54469420a62d2307fe04bbfa6dc5d..4b26f0bc408c54a0a98b4245a7929e36552a5819 100644 (file)
@@ -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'
index fb13f3ceb24503d47014f44cd28dc891c41f2788..452084a7c8e2c72c4782a6352214f06f64aaaa49 100644 (file)
@@ -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')
index 6ba30fac9823c281b7a3386ad515083a251e6489..2c3f7e542c36fc0e8643fa74ae9afc0941878bc1 100644 (file)
@@ -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,
index 7ce1a922f34d661b1e91d7a8831eeb236eb0f39f..e9b036a029b7870209fc3b6fc35675b7f968f48d 100644 (file)
@@ -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'
index f462df4b33d78e6f498f01111862fd5acac10349..78a897a65a738693e21585849f67a6425f6f3c62 100644 (file)
@@ -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'
index 8aff9f4972fa146b1534a78a45fa86fa03690398..38585c016bfac11ece94ea78201b695712197cd7 100644 (file)
@@ -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'
index e3eeb7dae1dc64b015b9cecde6d9258f2fa28024..1b272e1c82014bb11c1d952ff23b6e2626c5b158 100644 (file)
@@ -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'
index 5472c8b9287a9adc4debc65552231bc0dff10893..e8f603031de35838e1eb7c51e25cc309b24ba526 100644 (file)
@@ -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'
index 4558355244845332dbfd3aa806077c3f08c1cf0d..aaf1b8bd9e46f2b4a548245040f1ed8b6a385e56 100644 (file)
@@ -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'
index 39c50be5c1de3a923a5f612619023860257a889d..2b8e44223e40a0e183a8896a10eb2594f9e1da2e 100644 (file)
@@ -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'
index f8a71b270df9720359d2e3083a54f7e7a35cc5ee..a478bc62b43381757bd841908ca163e87cb38ee7 100644 (file)
@@ -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 }
 
index cc47644f233f5e06ab15811321c41468437d7301..eacd651cc1233dd4679d74cd0349a0f905b6aed3 100644 (file)
@@ -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',
index 86b1f6acb6272be9626dff7300109fa0faa3efbb..2619b49500c086c0a28f7299cd1f7964a39d2e3f 100644 (file)
@@ -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',
index c670bce71dc49599d497ff2fc4d4c890a4bec781..f2dbbfde82821570aa443bc67d5711e4ec66839f 100644 (file)
@@ -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'
index 1abc23eaa4547da8c08c1a8e2e775638ef56a2b5..5b50753445647923728d06df81c3f54c2bbb7b23 100644 (file)
@@ -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'
index 47f1cbb997327b30df6330c76ffd12a5f878f705..cb5f1cbbe067d2d73d22d4cb28205eed3c6c83d5 100644 (file)
@@ -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'
index 7915fc1f9c7f537820f30505b45715c01b8885b6..64771b1ff91de112f4c91eb6d02e50defbe3a623 100644 (file)
@@ -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,
index 9bc0f17f53efaa52b810a4678bb60aa38b41909e..ec10085d644db923579fef6837896ce6afa1a050 100644 (file)
@@ -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'
index a2bd225a16f84cb8a45313748e5b84495376905c..3396b11367902557073a87ef4f36698388836fbf 100644 (file)
@@ -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'
 
index 93f36a9d01e99e15a02bd1db7f93c599ce6e226e..0725b752a9432e22ceacfd54e421bda535d36874 100644 (file)
@@ -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'
index 39908156447aa672afbdb4faf91f7cd3e357dd13..c83f6c5b04711e20ca14dc0bb546e5f48f8521bb 100644 (file)
@@ -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'
index 0333755c5d9bb1e81cc92919ae34dc09db79949f..e50b5d1068b51a52d8cd2d8b1c6455b1d0fae00b 100644 (file)
@@ -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'
index 3b30e9e283bf0fdb8e569506f5cbd6b733abbeab..38447797e6b5d98ac9551ce53dba771660719bd8 100644 (file)
@@ -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'
index b7850407362d93f8bba168dc31590ac7a5d50b23..a923268460eb3a827616122bbd568d6d6ca96e35 100644 (file)
@@ -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'
index 6f6bc25a635393cfd87a2c78bdb470234ff45640..f84ba1ecefa9761e6c3d5589dc5a4215c546d5d5 100644 (file)
@@ -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
index 04e24e81847bbc60ce67a57e6a5e5367ee05f4d4..03f13b5e2681a49d4a2cdb6140bf5b7d3e482dd2 100644 (file)
@@ -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'
index e2348ace0df50ef2b54a5a38ab948ab05c5229a2..4762a8665efc0f6da1025b79e1ea16b36156dc1c 100644 (file)
@@ -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'