Don't expose constants directly in initializers/

pull/1765/head
Chocobozzz 2019-04-11 14:26:41 +02:00
parent 6dd9de95df
commit 74dc3bca2b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
114 changed files with 168 additions and 144 deletions

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

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

View File

@ -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

View File

@ -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'

View File

@ -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()
}

View File

@ -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', () => {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

View 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

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

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

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

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

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

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

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

View 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

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

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

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

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

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

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

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

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

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

View File

@ -1,5 +1,3 @@
// Constants first, database in second!
export * from './constants'
export * from './database'
export * from './installer'
export * from './migrator'

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

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

View File

@ -1,5 +1,4 @@
import * as Sequelize from 'sequelize'
import { CONSTRAINTS_FIELDS } from '../index'
async function up (utils: {
transaction: Sequelize.Transaction,

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

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

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

View 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

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

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

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

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

View 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

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

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

View 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

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

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

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

View 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

View 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

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

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

View 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Some files were not shown because too many files have changed in this diff Show More