import * as express from 'express'
import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
-import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers'
+import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers'
import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send'
import { audiencify, getAudience } from '../../lib/activitypub/audience'
import { buildCreateActivity } from '../../lib/activitypub/send/send-create'
import { ActorModel } from '../../models/activitypub/actor'
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
import { VideoModel } from '../../models/video/video'
-import { VideoChannelModel } from '../../models/video/video-channel'
import { VideoCommentModel } from '../../models/video/video-comment'
import { VideoShareModel } from '../../models/video/video-share'
import { cacheRoute } from '../../middlewares/cache'
import { VideoCaptionModel } from '../../models/video/video-caption'
import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy'
import { getServerActor } from '../../helpers/utils'
-import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike'
import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
import { VideoPlaylistModel } from '../../models/video/video-playlist'
-import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
const activityPubClientRouter = express.Router()
// We need more attributes
const video = await VideoModel.loadForGetAPI(res.locals.video.id)
- if (video.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(video.url)
+ if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url)
// We need captions to render AP object
video.VideoCaptions = await VideoCaptionModel.listVideoCaptions(video.id)
async function videoAnnounceController (req: express.Request, res: express.Response) {
const share = res.locals.videoShare
- if (share.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(share.url)
+ if (share.url.startsWith(WEBSERVER.URL) === false) return res.redirect(share.url)
const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.video, undefined)
async function videoCommentController (req: express.Request, res: express.Response) {
const videoComment = res.locals.videoComment
- if (videoComment.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoComment.url)
+ if (videoComment.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoComment.url)
const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined)
const isPublic = true // Comments are always public
async function videoRedundancyController (req: express.Request, res: express.Response) {
const videoRedundancy = res.locals.videoRedundancy
- if (videoRedundancy.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url)
+ if (videoRedundancy.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url)
const serverActor = await getServerActor()
return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count)
}
- return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page)
+ return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
}
async function actorFollowers (req: express.Request, actor: ActorModel) {
return ActorFollowModel.listAcceptedFollowerUrlsForAP([ actor.id ], undefined, start, count)
}
- return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page)
+ return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
}
async function actorPlaylists (req: express.Request, account: AccountModel) {
return VideoPlaylistModel.listPublicUrlsOfForAP(account.id, start, count)
}
- return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page)
+ return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
}
function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) {
import { About } from '../../../shared/models/server/about.model'
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
-import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers'
+import { CONSTRAINTS_FIELDS } from '../../initializers'
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
import { customConfigUpdateValidator } from '../../middlewares/validators/config'
import { ClientHtml } from '../../lib/client-html'
import { Emailer } from '../../lib/emailer'
import { isNumeric } from 'validator'
import { objectConverter } from '../../helpers/core-utils'
+import { CONFIG, reloadConfig } from '../../initializers/config'
const packageJSON = require('../../../../package.json')
const configRouter = express.Router()
import * as express from 'express'
import { OAuthClientLocal } from '../../../shared'
import { logger } from '../../helpers/logger'
-import { CONFIG } from '../../initializers'
+import { CONFIG } from '../../initializers/config'
import { asyncMiddleware } from '../../middlewares'
import { OAuthClientModel } from '../../models/oauth/oauth-client'
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
import { mtimeSortFilesDesc } from '../../../../shared/utils/logs/logs'
import { readdir, readFile } from 'fs-extra'
-import { CONFIG, MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers'
+import { MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers'
import { join } from 'path'
import { getLogsValidator } from '../../../middlewares/validators/logs'
import { LogLevel } from '../../../../shared/models/server/log-level.type'
+import { CONFIG } from '../../../initializers/config'
const logsRouter = express.Router()
import { VideoModel } from '../../../models/video/video'
import { VideoCommentModel } from '../../../models/video/video-comment'
import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy'
-import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
+import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
import { cacheRoute } from '../../../middlewares/cache'
import { VideoFileModel } from '../../../models/video/video-file'
+import { CONFIG } from '../../../initializers/config'
const statsRouter = express.Router()
import { UserCreate, UserRight, UserRole, UserUpdate } from '../../../../shared'
import { logger } from '../../../helpers/logger'
import { getFormattedObjects } from '../../../helpers/utils'
-import { CONFIG, RATES_LIMIT, sequelizeTypescript } from '../../../initializers'
+import { RATES_LIMIT, sequelizeTypescript, WEBSERVER } from '../../../initializers'
import { Emailer } from '../../../lib/emailer'
import { Redis } from '../../../lib/redis'
import { createUserAccountAndChannelAndPlaylist } from '../../../lib/user'
import { myNotificationsRouter } from './my-notifications'
import { Notifier } from '../../../lib/notifier'
import { mySubscriptionsRouter } from './my-subscriptions'
+import { CONFIG } from '../../../initializers/config'
const auditLogger = auditLoggerFactory('users')
const user = res.locals.user
const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id)
- const url = CONFIG.WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
+ const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
await Emailer.Instance.addPasswordResetEmailJob(user.email, url)
return res.status(204).end()
async function sendVerifyUserEmail (user: UserModel) {
const verificationString = await Redis.Instance.setVerifyEmailVerificationString(user.id)
- const url = CONFIG.WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString
+ const url = WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString
await Emailer.Instance.addVerifyEmailJob(user.email, url)
return
}
import 'multer'
import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared'
import { getFormattedObjects } from '../../../helpers/utils'
-import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers'
+import { MIMETYPES, sequelizeTypescript } from '../../../initializers'
import { sendUpdateActor } from '../../../lib/activitypub/send'
import {
asyncMiddleware,
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
import { VideoImportModel } from '../../../models/video/video-import'
import { AccountModel } from '../../../models/account/account'
+import { CONFIG } from '../../../initializers/config'
const auditLogger = auditLoggerFactory('users-me')
import * as express from 'express'
import 'multer'
import { getFormattedObjects } from '../../../helpers/utils'
-import { CONFIG, sequelizeTypescript } from '../../../initializers'
+import { sequelizeTypescript, WEBSERVER } from '../../../initializers'
import {
asyncMiddleware,
asyncRetryTransactionMiddleware,
const handles = uris.map(u => {
let [ name, host ] = u.split('@')
- if (host === CONFIG.WEBSERVER.HOST) host = null
+ if (host === WEBSERVER.HOST) host = null
return { name, host, uri: u }
})
import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
import { setAsyncActorKeys } from '../../lib/activitypub'
import { AccountModel } from '../../models/account/account'
-import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers'
+import { MIMETYPES, sequelizeTypescript } from '../../initializers'
import { logger } from '../../helpers/logger'
import { VideoModel } from '../../models/video/video'
import { updateAvatarValidator } from '../../middlewares/validators/avatar'
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'
const auditLogger = auditLoggerFactory('channels')
const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
} from '../../middlewares'
import { videoPlaylistsSortValidator } from '../../middlewares/validators'
import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
-import { CONFIG, MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers'
+import { MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers'
import { logger } from '../../helpers/logger'
import { resetSequelizeInstance } from '../../helpers/database-utils'
import { VideoPlaylistModel } from '../../models/video/video-playlist'
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'
const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR })
import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares'
import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators'
import { createReqFiles } from '../../../helpers/express-utils'
-import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers'
+import { MIMETYPES, sequelizeTypescript } from '../../../initializers'
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'
const reqVideoCaptionAdd = createReqFiles(
[ 'captionfile' ],
import 'multer'
import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger'
import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'
-import { CONFIG, MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers'
+import { MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers'
import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl'
import { createReqFiles } from '../../../helpers/express-utils'
import { logger } from '../../../helpers/logger'
import * as Bluebird from 'bluebird'
import * as parseTorrent from 'parse-torrent'
import { getSecureTorrentName } from '../../../helpers/utils'
-import { readFile, move } from 'fs-extra'
+import { move, readFile } from 'fs-extra'
import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
+import { CONFIG } from '../../../initializers/config'
const auditLogger = auditLoggerFactory('video-imports')
const videoImportsRouter = express.Router()
import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
import {
- CONFIG,
MIMETYPES,
PREVIEWS_SIZE,
sequelizeTypescript,
import { watchingRouter } from './watching'
import { Notifier } from '../../../lib/notifier'
import { sendView } from '../../../lib/activitypub/send/send-view'
+import { CONFIG } from '../../../initializers/config'
const auditLogger = auditLoggerFactory('videos')
const videosRouter = express.Router()
import * as express from 'express'
import { asyncMiddleware } from '../middlewares'
-import { CONFIG, ROUTE_CACHE_LIFETIME } from '../initializers'
+import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers'
import * as sitemapModule from 'sitemap'
import { logger } from '../helpers/logger'
import { VideoModel } from '../models/video/video'
urls = urls.concat(await getSitemapAccountUrls())
const sitemap = sitemapModule.createSitemap({
- hostname: CONFIG.WEBSERVER.URL,
+ hostname: WEBSERVER.URL,
urls: urls
})
const rows = await VideoChannelModel.listLocalsForSitemap('createdAt')
return rows.map(channel => ({
- url: CONFIG.WEBSERVER.URL + '/video-channels/' + channel.Actor.preferredUsername
+ url: WEBSERVER.URL + '/video-channels/' + channel.Actor.preferredUsername
}))
}
const rows = await AccountModel.listLocalsForSitemap('createdAt')
return rows.map(channel => ({
- url: CONFIG.WEBSERVER.URL + '/accounts/' + channel.Actor.preferredUsername
+ url: WEBSERVER.URL + '/accounts/' + channel.Actor.preferredUsername
}))
}
})
return resultList.data.map(v => ({
- url: CONFIG.WEBSERVER.URL + '/videos/watch/' + v.uuid,
+ url: WEBSERVER.URL + '/videos/watch/' + v.uuid,
video: [
{
title: v.name,
// Sitemap description should be < 2000 characters
description: truncate(v.description || v.name, { length: 2000, omission: '...' }),
- player_loc: CONFIG.WEBSERVER.URL + '/videos/embed/' + v.uuid,
- thumbnail_loc: CONFIG.WEBSERVER.URL + v.getThumbnailStaticPath()
+ player_loc: WEBSERVER.URL + '/videos/embed/' + v.uuid,
+ thumbnail_loc: WEBSERVER.URL + v.getThumbnailStaticPath()
}
]
}))
'/videos/local'
]
- return paths.map(p => ({ url: CONFIG.WEBSERVER.URL + p }))
+ return paths.map(p => ({ url: WEBSERVER.URL + p }))
}
import * as express from 'express'
-import { CONFIG, FEEDS, ROUTE_CACHE_LIFETIME } from '../initializers/constants'
+import { FEEDS, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
import { THUMBNAILS_SIZE } from '../initializers'
import {
asyncMiddleware,
import { cacheRoute } from '../middlewares/cache'
import { VideoCommentModel } from '../models/video/video-comment'
import { buildNSFWFilter } from '../helpers/express-utils'
+import { CONFIG } from '../initializers/config'
const feedsRouter = express.Router()
// Adding video items to the feed, one at a time
comments.forEach(comment => {
- const link = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath()
+ const link = WEBSERVER.URL + comment.getCommentStaticPath()
feed.addItem({
title: `${comment.Video.name} - ${comment.Account.getDisplayName()}`,
feed.addItem({
title: video.name,
id: video.url,
- link: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid,
+ link: WEBSERVER.URL + '/videos/watch/' + video.uuid,
description: video.getTruncatedDescription(),
content: video.description,
author: [
torrent: torrents,
thumbnail: [
{
- url: CONFIG.WEBSERVER.URL + video.getThumbnailStaticPath(),
+ url: WEBSERVER.URL + video.getThumbnailStaticPath(),
height: THUMBNAILS_SIZE.height,
width: THUMBNAILS_SIZE.width
}
}
function initFeed (name: string, description: string) {
- const webserverUrl = CONFIG.WEBSERVER.URL
+ const webserverUrl = WEBSERVER.URL
return new Feed({
title: name,
import * as express from 'express'
-import { CONFIG, EMBED_SIZE, PREVIEWS_SIZE } from '../initializers'
+import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER } from '../initializers'
import { asyncMiddleware, oembedValidator } from '../middlewares'
import { accountNameWithHostGetValidator } from '../middlewares/validators'
-import { VideoModel } from '../models/video/video'
+import { CONFIG } from '../initializers/config'
const servicesRouter = express.Router()
function generateOEmbed (req: express.Request, res: express.Response) {
const video = res.locals.video
- const webserverUrl = CONFIG.WEBSERVER.URL
+ const webserverUrl = WEBSERVER.URL
const maxHeight = parseInt(req.query.maxheight, 10)
const maxWidth = parseInt(req.query.maxwidth, 10)
import * as cors from 'cors'
import * as express from 'express'
import {
- CONFIG,
HLS_STREAMING_PLAYLIST_DIRECTORY,
ROUTE_CACHE_LIFETIME,
STATIC_DOWNLOAD_PATHS,
STATIC_MAX_AGE,
- STATIC_PATHS
+ STATIC_PATHS,
+ WEBSERVER
} from '../initializers'
import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache'
import { cacheRoute } from '../middlewares/cache'
import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo'
import { join } from 'path'
import { root } from '../helpers/core-utils'
+import { CONFIG } from '../initializers/config'
const packageJSON = require('../../../package.json')
const staticRouter = express.Router()
links: [
{
rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0',
- href: CONFIG.WEBSERVER.URL + '/nodeinfo/2.0.json'
+ href: WEBSERVER.URL + '/nodeinfo/2.0.json'
}
]
})
import * as bitTorrentTracker from 'bittorrent-tracker'
import * as proxyAddr from 'proxy-addr'
import { Server as WebSocketServer } from 'ws'
-import { CONFIG, TRACKER_RATE_LIMITS } from '../initializers/constants'
+import { TRACKER_RATE_LIMITS } from '../initializers/constants'
import { VideoFileModel } from '../models/video/video-file'
import { parse } from 'url'
import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
+import { CONFIG } from '../initializers/config'
const TrackerServer = bitTorrentTracker.Server
import { chain } from 'lodash'
import * as flatten from 'flat'
import * as winston from 'winston'
-import { CONFIG } from '../initializers'
import { jsonLoggerFormat, labelFormatter } from './logger'
import { User, VideoAbuse, VideoChannel, VideoDetails, VideoImport } from '../../shared'
import { VideoComment } from '../../shared/models/videos/video-comment.model'
import { CustomConfig } from '../../shared/models/server/custom-config.model'
+import { CONFIG } from '../initializers/config'
function getAuditIdFromRes (res: express.Response) {
return res.locals.oauth.token.User.username
import { join } from 'path'
-import { CONFIG } from '../initializers'
+import { CONFIG } from '../initializers/config'
import { VideoCaptionModel } from '../models/video/video-caption'
import * as srt2vtt from 'srt-to-vtt'
import { createReadStream, createWriteStream, remove, move } from 'fs-extra'
import 'express-validator'
import 'multer'
import * as validator from 'validator'
-import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers'
+import { CONSTRAINTS_FIELDS } from '../../initializers'
import { VideoChannelModel } from '../../models/video/video-channel'
import { exists } from './misc'
-import { CONFIG, REMOTE_SCHEME } from '../../initializers'
+import { REMOTE_SCHEME, WEBSERVER } from '../../initializers'
import { sanitizeHost } from '../core-utils'
import { exists } from './misc'
if (actorParts.length !== 2) return false
const host = actorParts[1]
- return sanitizeHost(host, REMOTE_SCHEME.HTTP) === CONFIG.WEBSERVER.HOST
+ return sanitizeHost(host, REMOTE_SCHEME.HTTP) === WEBSERVER.HOST
}
// ---------------------------------------------------------------------------
import * as express from 'express'
import * as multer from 'multer'
-import { CONFIG, REMOTE_SCHEME } from '../initializers'
+import { REMOTE_SCHEME } from '../initializers'
import { logger } from './logger'
import { deleteFileAsync, generateRandomString } from './utils'
import { extname } from 'path'
import { isArray } from './custom-validators/misc'
+import { CONFIG } from '../initializers/config'
function buildNSFWFilter (res?: express.Response, paramNSFW?: string) {
if (paramNSFW === 'true') return true
return host
}
-function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) {
+function badRequest (req: express.Request, res: express.Response) {
return res.type('json').status(400).end()
}
import * as ffmpeg from 'fluent-ffmpeg'
import { dirname, join } from 'path'
import { getTargetBitrate, VideoResolution } from '../../shared/models/videos'
-import { CONFIG, FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants'
+import { FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants'
import { processImage } from './image-utils'
import { logger } from './logger'
import { checkFFmpegEncoders } from '../initializers/checker-before-init'
-import { remove, readFile, writeFile } from 'fs-extra'
+import { readFile, remove, writeFile } from 'fs-extra'
+import { CONFIG } from '../initializers/config'
function computeResolutionsToTranscode (videoFileHeight: number) {
const resolutionsEnabled: number[] = []
import { mkdirpSync } from 'fs-extra'
import * as path from 'path'
import * as winston from 'winston'
-import { CONFIG } from '../initializers'
+import { CONFIG } from '../initializers/config'
import { omit } from 'lodash'
const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
import * as Bluebird from 'bluebird'
import { createWriteStream, remove } from 'fs-extra'
import * as request from 'request'
-import { ACTIVITY_PUB, CONFIG } from '../initializers'
+import { ACTIVITY_PUB } from '../initializers'
import { processImage } from './image-utils'
import { join } from 'path'
import { logger } from './logger'
+import { CONFIG } from '../initializers/config'
function doRequest <T> (
requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean },
-import { CONFIG } from '../initializers'
import { UserModel } from '../models/account/user'
import * as ipaddr from 'ipaddr.js'
+import { CONFIG } from '../initializers/config'
+
const isCidr = require('is-cidr')
async function isSignupAllowed () {
import { ResultList } from '../../shared'
-import { CONFIG } from '../initializers'
import { ApplicationModel } from '../models/application/application'
import { execPromise, execPromise2, pseudoRandomBytesPromise, sha256 } from './core-utils'
import { logger } from './logger'
import { Instance as ParseTorrent } from 'parse-torrent'
import { remove } from 'fs-extra'
import * as memoizee from 'memoizee'
+import { CONFIG } from '../initializers/config'
function deleteFileAsync (path: string) {
remove(path)
import { ActorModel } from '../models/activitypub/actor'
import { isTestInstance } from './core-utils'
import { isActivityPubUrlValid } from './custom-validators/activitypub/misc'
-import { CONFIG } from '../initializers'
+import { WEBSERVER } from '../initializers/constants'
const webfinger = new WebFinger({
webfist_fallback: false,
const [ name, host ] = uri.split('@')
let actor: ActorModel
- if (host === CONFIG.WEBSERVER.HOST) {
+ if (host === WEBSERVER.HOST) {
actor = await ActorModel.loadLocalByName(name)
} else {
actor = await ActorModel.loadByNameAndHost(name, host)
import { generateVideoImportTmpPath } from './utils'
import * as WebTorrent from 'webtorrent'
import { createWriteStream, ensureDir, remove } from 'fs-extra'
-import { CONFIG } from '../initializers'
+import { CONFIG } from '../initializers/config'
import { dirname, join } from 'path'
async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) {
import { ApplicationModel } from '../models/application/application'
import { OAuthClientModel } from '../models/oauth/oauth-client'
import { parse } from 'url'
-import { CONFIG } from './constants'
+import { CONFIG } from './config'
import { logger } from '../helpers/logger'
import { getServerActor } from '../helpers/utils'
import { RecentlyAddedStrategy } from '../../shared/models/redundancy'
import { isArray } from '../helpers/custom-validators/misc'
import { uniq } from 'lodash'
import { Emailer } from '../lib/emailer'
+import { WEBSERVER } from './constants'
async function checkActivityPubUrls () {
const actor = await getServerActor()
const parsed = parse(actor.url)
- if (CONFIG.WEBSERVER.HOST !== parsed.host) {
+ if (WEBSERVER.HOST !== parsed.host) {
const NODE_ENV = config.util.getEnv('NODE_ENV')
const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR')
--- /dev/null
+import { IConfig } from 'config'
+import { dirname, join } from 'path'
+import { VideosRedundancy } from '../../shared/models'
+// Do not use barrels, remain constants as independent as possible
+import { buildPath, parseBytes, parseDuration, root } from '../helpers/core-utils'
+import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
+import * as bytes from 'bytes'
+
+// Use a variable to reload the configuration if we need
+let config: IConfig = require('config')
+
+const configChangedHandlers: Function[] = []
+
+const CONFIG = {
+ CUSTOM_FILE: getLocalConfigFilePath(),
+ LISTEN: {
+ PORT: config.get<number>('listen.port'),
+ HOSTNAME: config.get<string>('listen.hostname')
+ },
+ DATABASE: {
+ DBNAME: 'peertube' + config.get<string>('database.suffix'),
+ HOSTNAME: config.get<string>('database.hostname'),
+ PORT: config.get<number>('database.port'),
+ USERNAME: config.get<string>('database.username'),
+ PASSWORD: config.get<string>('database.password'),
+ POOL: {
+ MAX: config.get<number>('database.pool.max')
+ }
+ },
+ REDIS: {
+ HOSTNAME: config.has('redis.hostname') ? config.get<string>('redis.hostname') : null,
+ PORT: config.has('redis.port') ? config.get<number>('redis.port') : null,
+ SOCKET: config.has('redis.socket') ? config.get<string>('redis.socket') : null,
+ AUTH: config.has('redis.auth') ? config.get<string>('redis.auth') : null,
+ DB: config.has('redis.db') ? config.get<number>('redis.db') : null
+ },
+ SMTP: {
+ HOSTNAME: config.get<string>('smtp.hostname'),
+ PORT: config.get<number>('smtp.port'),
+ USERNAME: config.get<string>('smtp.username'),
+ PASSWORD: config.get<string>('smtp.password'),
+ TLS: config.get<boolean>('smtp.tls'),
+ DISABLE_STARTTLS: config.get<boolean>('smtp.disable_starttls'),
+ CA_FILE: config.get<string>('smtp.ca_file'),
+ FROM_ADDRESS: config.get<string>('smtp.from_address')
+ },
+ STORAGE: {
+ TMP_DIR: buildPath(config.get<string>('storage.tmp')),
+ AVATARS_DIR: buildPath(config.get<string>('storage.avatars')),
+ LOG_DIR: buildPath(config.get<string>('storage.logs')),
+ VIDEOS_DIR: buildPath(config.get<string>('storage.videos')),
+ STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')),
+ REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')),
+ THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')),
+ PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')),
+ CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')),
+ TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')),
+ CACHE_DIR: buildPath(config.get<string>('storage.cache'))
+ },
+ WEBSERVER: {
+ SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http',
+ WS: config.get<boolean>('webserver.https') === true ? 'wss' : 'ws',
+ HOSTNAME: config.get<string>('webserver.hostname'),
+ PORT: config.get<number>('webserver.port')
+ },
+ TRUST_PROXY: config.get<string[]>('trust_proxy'),
+ LOG: {
+ LEVEL: config.get<string>('log.level')
+ },
+ SEARCH: {
+ REMOTE_URI: {
+ USERS: config.get<boolean>('search.remote_uri.users'),
+ ANONYMOUS: config.get<boolean>('search.remote_uri.anonymous')
+ }
+ },
+ TRENDING: {
+ VIDEOS: {
+ INTERVAL_DAYS: config.get<number>('trending.videos.interval_days')
+ }
+ },
+ REDUNDANCY: {
+ VIDEOS: {
+ CHECK_INTERVAL: parseDuration(config.get<string>('redundancy.videos.check_interval')),
+ STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies'))
+ }
+ },
+ CSP: {
+ ENABLED: config.get<boolean>('csp.enabled'),
+ REPORT_ONLY: config.get<boolean>('csp.report_only'),
+ REPORT_URI: config.get<boolean>('csp.report_uri')
+ },
+ TRACKER: {
+ ENABLED: config.get<boolean>('tracker.enabled'),
+ PRIVATE: config.get<boolean>('tracker.private'),
+ REJECT_TOO_MANY_ANNOUNCES: config.get<boolean>('tracker.reject_too_many_announces')
+ },
+ ADMIN: {
+ get EMAIL () { return config.get<string>('admin.email') }
+ },
+ CONTACT_FORM: {
+ get ENABLED () { return config.get<boolean>('contact_form.enabled') }
+ },
+ SIGNUP: {
+ get ENABLED () { return config.get<boolean>('signup.enabled') },
+ get LIMIT () { return config.get<number>('signup.limit') },
+ get REQUIRES_EMAIL_VERIFICATION () { return config.get<boolean>('signup.requires_email_verification') },
+ FILTERS: {
+ CIDR: {
+ get WHITELIST () { return config.get<string[]>('signup.filters.cidr.whitelist') },
+ get BLACKLIST () { return config.get<string[]>('signup.filters.cidr.blacklist') }
+ }
+ }
+ },
+ USER: {
+ get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) },
+ get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) }
+ },
+ TRANSCODING: {
+ get ENABLED () { return config.get<boolean>('transcoding.enabled') },
+ get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') },
+ get THREADS () { return config.get<number>('transcoding.threads') },
+ RESOLUTIONS: {
+ get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') },
+ get '360p' () { return config.get<boolean>('transcoding.resolutions.360p') },
+ get '480p' () { return config.get<boolean>('transcoding.resolutions.480p') },
+ get '720p' () { return config.get<boolean>('transcoding.resolutions.720p') },
+ get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') }
+ },
+ HLS: {
+ get ENABLED () { return config.get<boolean>('transcoding.hls.enabled') }
+ }
+ },
+ IMPORT: {
+ VIDEOS: {
+ HTTP: {
+ get ENABLED () { return config.get<boolean>('import.videos.http.enabled') }
+ },
+ TORRENT: {
+ get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') }
+ }
+ }
+ },
+ AUTO_BLACKLIST: {
+ VIDEOS: {
+ OF_USERS: {
+ get ENABLED () { return config.get<boolean>('auto_blacklist.videos.of_users.enabled') }
+ }
+ }
+ },
+ CACHE: {
+ PREVIEWS: {
+ get SIZE () { return config.get<number>('cache.previews.size') }
+ },
+ VIDEO_CAPTIONS: {
+ get SIZE () { return config.get<number>('cache.captions.size') }
+ }
+ },
+ INSTANCE: {
+ get NAME () { return config.get<string>('instance.name') },
+ get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') },
+ get DESCRIPTION () { return config.get<string>('instance.description') },
+ get TERMS () { return config.get<string>('instance.terms') },
+ get IS_NSFW () { return config.get<boolean>('instance.is_nsfw') },
+ get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') },
+ get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') },
+ CUSTOMIZATIONS: {
+ get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') },
+ get CSS () { return config.get<string>('instance.customizations.css') }
+ },
+ get ROBOTS () { return config.get<string>('instance.robots') },
+ get SECURITYTXT () { return config.get<string>('instance.securitytxt') },
+ get SECURITYTXT_CONTACT () { return config.get<string>('admin.email') }
+ },
+ SERVICES: {
+ TWITTER: {
+ get USERNAME () { return config.get<string>('services.twitter.username') },
+ get WHITELISTED () { return config.get<boolean>('services.twitter.whitelisted') }
+ }
+ },
+ FOLLOWERS: {
+ INSTANCE: {
+ get ENABLED () { return config.get<boolean>('followers.instance.enabled') },
+ get MANUAL_APPROVAL () { return config.get<boolean>('followers.instance.manual_approval') }
+ }
+ }
+}
+
+function registerConfigChangedHandler (fun: Function) {
+ configChangedHandlers.push(fun)
+}
+
+// ---------------------------------------------------------------------------
+
+export {
+ CONFIG,
+ registerConfigChangedHandler
+}
+
+// ---------------------------------------------------------------------------
+
+function getLocalConfigFilePath () {
+ const configSources = config.util.getConfigSources()
+ if (configSources.length === 0) throw new Error('Invalid config source.')
+
+ let filename = 'local'
+ if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}`
+ if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}`
+
+ return join(dirname(configSources[ 0 ].name), filename + '.json')
+}
+
+function buildVideosRedundancy (objs: any[]): VideosRedundancy[] {
+ if (!objs) return []
+
+ if (!Array.isArray(objs)) return objs
+
+ return objs.map(obj => {
+ return Object.assign({}, obj, {
+ minLifetime: parseDuration(obj.min_lifetime),
+ size: bytes.parse(obj.size),
+ minViews: obj.min_views
+ })
+ })
+}
+
+export function reloadConfig () {
+
+ function directory () {
+ if (process.env.NODE_CONFIG_DIR) {
+ return process.env.NODE_CONFIG_DIR
+ }
+
+ return join(root(), 'config')
+ }
+
+ function purge () {
+ for (const fileName in require.cache) {
+ if (-1 === fileName.indexOf(directory())) {
+ continue
+ }
+
+ delete require.cache[fileName]
+ }
+
+ delete require.cache[require.resolve('config')]
+ }
+
+ purge()
+
+ config = require('config')
+
+ for (const configChangedHandler of configChangedHandlers) {
+ configChangedHandler()
+ }
+}
-import { IConfig } from 'config'
-import { dirname, join } from 'path'
-import { JobType, VideoRateType, VideoState, VideosRedundancy } from '../../shared/models'
+import { join } from 'path'
+import { JobType, VideoRateType, VideoState } from '../../shared/models'
import { ActivityPubActorType } from '../../shared/models/activitypub'
import { FollowState } from '../../shared/models/actors'
import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos'
// Do not use barrels, remain constants as independent as possible
-import { buildPath, isTestInstance, parseDuration, parseBytes, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
+import { isTestInstance, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
import { invert } from 'lodash'
import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
-import * as bytes from 'bytes'
import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'
import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'
-
-// Use a variable to reload the configuration if we need
-let config: IConfig = require('config')
+import { CONFIG, registerConfigChangedHandler } from './config'
// ---------------------------------------------------------------------------
}
}
+const WEBSERVER = {
+ URL: '',
+ HOST: '',
+ SCHEME: '',
+ WS: '',
+ HOSTNAME: '',
+ PORT: 0
+}
+
// Sortable columns per schema
const SORTABLE_COLUMNS = {
USERS: [ 'id', 'username', 'createdAt' ],
}
// TODO: remove 'video-file'
-const JOB_ATTEMPTS: { [ id in (JobType | 'video-file') ]: number } = {
+const JOB_ATTEMPTS: { [id in (JobType | 'video-file')]: number } = {
'activitypub-http-broadcast': 5,
'activitypub-http-unicast': 5,
'activitypub-http-fetcher': 5,
'videos-views': 1,
'activitypub-refresher': 1
}
-const JOB_CONCURRENCY: { [ id in (JobType | 'video-file') ]: number } = {
+const JOB_CONCURRENCY: { [id in (JobType | 'video-file')]: number } = {
'activitypub-http-broadcast': 1,
'activitypub-http-unicast': 5,
'activitypub-http-fetcher': 1,
'videos-views': 1,
'activitypub-refresher': 1
}
-const JOB_TTL: { [ id in (JobType | 'video-file') ]: number } = {
+const JOB_TTL: { [id in (JobType | 'video-file')]: number } = {
'activitypub-http-broadcast': 60000 * 10, // 10 minutes
'activitypub-http-unicast': 60000 * 10, // 10 minutes
'activitypub-http-fetcher': 60000 * 10, // 10 minutes
// ---------------------------------------------------------------------------
-const CONFIG = {
- CUSTOM_FILE: getLocalConfigFilePath(),
- LISTEN: {
- PORT: config.get<number>('listen.port'),
- HOSTNAME: config.get<string>('listen.hostname')
- },
- DATABASE: {
- DBNAME: 'peertube' + config.get<string>('database.suffix'),
- HOSTNAME: config.get<string>('database.hostname'),
- PORT: config.get<number>('database.port'),
- USERNAME: config.get<string>('database.username'),
- PASSWORD: config.get<string>('database.password'),
- POOL: {
- MAX: config.get<number>('database.pool.max')
- }
- },
- REDIS: {
- HOSTNAME: config.has('redis.hostname') ? config.get<string>('redis.hostname') : null,
- PORT: config.has('redis.port') ? config.get<number>('redis.port') : null,
- SOCKET: config.has('redis.socket') ? config.get<string>('redis.socket') : null,
- AUTH: config.has('redis.auth') ? config.get<string>('redis.auth') : null,
- DB: config.has('redis.db') ? config.get<number>('redis.db') : null
- },
- SMTP: {
- HOSTNAME: config.get<string>('smtp.hostname'),
- PORT: config.get<number>('smtp.port'),
- USERNAME: config.get<string>('smtp.username'),
- PASSWORD: config.get<string>('smtp.password'),
- TLS: config.get<boolean>('smtp.tls'),
- DISABLE_STARTTLS: config.get<boolean>('smtp.disable_starttls'),
- CA_FILE: config.get<string>('smtp.ca_file'),
- FROM_ADDRESS: config.get<string>('smtp.from_address')
- },
- STORAGE: {
- TMP_DIR: buildPath(config.get<string>('storage.tmp')),
- AVATARS_DIR: buildPath(config.get<string>('storage.avatars')),
- LOG_DIR: buildPath(config.get<string>('storage.logs')),
- VIDEOS_DIR: buildPath(config.get<string>('storage.videos')),
- STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')),
- REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')),
- THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')),
- PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')),
- CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')),
- TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')),
- CACHE_DIR: buildPath(config.get<string>('storage.cache'))
- },
- WEBSERVER: {
- SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http',
- WS: config.get<boolean>('webserver.https') === true ? 'wss' : 'ws',
- HOSTNAME: config.get<string>('webserver.hostname'),
- PORT: config.get<number>('webserver.port'),
- URL: '',
- HOST: ''
- },
- TRUST_PROXY: config.get<string[]>('trust_proxy'),
- LOG: {
- LEVEL: config.get<string>('log.level')
- },
- SEARCH: {
- REMOTE_URI: {
- USERS: config.get<boolean>('search.remote_uri.users'),
- ANONYMOUS: config.get<boolean>('search.remote_uri.anonymous')
- }
- },
- TRENDING: {
- VIDEOS: {
- INTERVAL_DAYS: config.get<number>('trending.videos.interval_days')
- }
- },
- REDUNDANCY: {
- VIDEOS: {
- CHECK_INTERVAL: parseDuration(config.get<string>('redundancy.videos.check_interval')),
- STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies'))
- }
- },
- CSP: {
- ENABLED: config.get<boolean>('csp.enabled'),
- REPORT_ONLY: config.get<boolean>('csp.report_only'),
- REPORT_URI: config.get<boolean>('csp.report_uri')
- },
- TRACKER: {
- ENABLED: config.get<boolean>('tracker.enabled'),
- PRIVATE: config.get<boolean>('tracker.private'),
- REJECT_TOO_MANY_ANNOUNCES: config.get<boolean>('tracker.reject_too_many_announces')
- },
- ADMIN: {
- get EMAIL () { return config.get<string>('admin.email') }
- },
- CONTACT_FORM: {
- get ENABLED () { return config.get<boolean>('contact_form.enabled') }
- },
- SIGNUP: {
- get ENABLED () { return config.get<boolean>('signup.enabled') },
- get LIMIT () { return config.get<number>('signup.limit') },
- get REQUIRES_EMAIL_VERIFICATION () { return config.get<boolean>('signup.requires_email_verification') },
- FILTERS: {
- CIDR: {
- get WHITELIST () { return config.get<string[]>('signup.filters.cidr.whitelist') },
- get BLACKLIST () { return config.get<string[]>('signup.filters.cidr.blacklist') }
- }
- }
- },
- USER: {
- get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) },
- get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) }
- },
- TRANSCODING: {
- get ENABLED () { return config.get<boolean>('transcoding.enabled') },
- get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') },
- get THREADS () { return config.get<number>('transcoding.threads') },
- RESOLUTIONS: {
- get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') },
- get '360p' () { return config.get<boolean>('transcoding.resolutions.360p') },
- get '480p' () { return config.get<boolean>('transcoding.resolutions.480p') },
- get '720p' () { return config.get<boolean>('transcoding.resolutions.720p') },
- get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') }
- },
- HLS: {
- get ENABLED () { return config.get<boolean>('transcoding.hls.enabled') }
- }
- },
- IMPORT: {
- VIDEOS: {
- HTTP: {
- get ENABLED () { return config.get<boolean>('import.videos.http.enabled') }
- },
- TORRENT: {
- get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') }
- }
- }
- },
- AUTO_BLACKLIST: {
- VIDEOS: {
- OF_USERS: {
- get ENABLED () { return config.get<boolean>('auto_blacklist.videos.of_users.enabled') }
- }
- }
- },
- CACHE: {
- PREVIEWS: {
- get SIZE () { return config.get<number>('cache.previews.size') }
- },
- VIDEO_CAPTIONS: {
- get SIZE () { return config.get<number>('cache.captions.size') }
- }
- },
- INSTANCE: {
- get NAME () { return config.get<string>('instance.name') },
- get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') },
- get DESCRIPTION () { return config.get<string>('instance.description') },
- get TERMS () { return config.get<string>('instance.terms') },
- get IS_NSFW () { return config.get<boolean>('instance.is_nsfw') },
- get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') },
- get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') },
- CUSTOMIZATIONS: {
- get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') },
- get CSS () { return config.get<string>('instance.customizations.css') }
- },
- get ROBOTS () { return config.get<string>('instance.robots') },
- get SECURITYTXT () { return config.get<string>('instance.securitytxt') },
- get SECURITYTXT_CONTACT () { return config.get<string>('admin.email') }
- },
- SERVICES: {
- TWITTER: {
- get USERNAME () { return config.get<string>('services.twitter.username') },
- get WHITELISTED () { return config.get<boolean>('services.twitter.whitelisted') }
- }
- },
- FOLLOWERS: {
- INSTANCE: {
- get ENABLED () { return config.get<boolean>('followers.instance.enabled') },
- get MANUAL_APPROVAL () { return config.get<boolean>('followers.instance.manual_approval') }
- }
- }
-}
-
-// ---------------------------------------------------------------------------
-
let CONSTRAINTS_FIELDS = {
USERS: {
NAME: { min: 1, max: 120 }, // Length
const VIDEO_LANGUAGES = buildLanguages()
const VIDEO_PRIVACIES = {
- [VideoPrivacy.PUBLIC]: 'Public',
- [VideoPrivacy.UNLISTED]: 'Unlisted',
- [VideoPrivacy.PRIVATE]: 'Private'
+ [ VideoPrivacy.PUBLIC ]: 'Public',
+ [ VideoPrivacy.UNLISTED ]: 'Unlisted',
+ [ VideoPrivacy.PRIVATE ]: 'Private'
}
const VIDEO_STATES = {
- [VideoState.PUBLISHED]: 'Published',
- [VideoState.TO_TRANSCODE]: 'To transcode',
- [VideoState.TO_IMPORT]: 'To import'
+ [ VideoState.PUBLISHED ]: 'Published',
+ [ VideoState.TO_TRANSCODE ]: 'To transcode',
+ [ VideoState.TO_IMPORT ]: 'To import'
}
const VIDEO_IMPORT_STATES = {
- [VideoImportState.FAILED]: 'Failed',
- [VideoImportState.PENDING]: 'Pending',
- [VideoImportState.SUCCESS]: 'Success'
+ [ VideoImportState.FAILED ]: 'Failed',
+ [ VideoImportState.PENDING ]: 'Pending',
+ [ VideoImportState.SUCCESS ]: 'Success'
}
const VIDEO_ABUSE_STATES = {
- [VideoAbuseState.PENDING]: 'Pending',
- [VideoAbuseState.REJECTED]: 'Rejected',
- [VideoAbuseState.ACCEPTED]: 'Accepted'
+ [ VideoAbuseState.PENDING ]: 'Pending',
+ [ VideoAbuseState.REJECTED ]: 'Rejected',
+ [ VideoAbuseState.ACCEPTED ]: 'Accepted'
}
const VIDEO_PLAYLIST_PRIVACIES = {
- [VideoPlaylistPrivacy.PUBLIC]: 'Public',
- [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted',
- [VideoPlaylistPrivacy.PRIVATE]: 'Private'
+ [ VideoPlaylistPrivacy.PUBLIC ]: 'Public',
+ [ VideoPlaylistPrivacy.UNLISTED ]: 'Unlisted',
+ [ VideoPlaylistPrivacy.PRIVATE ]: 'Private'
}
const VIDEO_PLAYLIST_TYPES = {
- [VideoPlaylistType.REGULAR]: 'Regular',
- [VideoPlaylistType.WATCH_LATER]: 'Watch later'
+ [ VideoPlaylistType.REGULAR ]: 'Regular',
+ [ VideoPlaylistType.WATCH_LATER ]: 'Watch later'
}
const MIMETYPES = {
const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes
-const NSFW_POLICY_TYPES: { [ id: string]: NSFWPolicyType } = {
+const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = {
DO_NOT_LIST: 'do_not_list',
BLUR: 'blur',
DISPLAY: 'display'
SCHEDULER_INTERVALS_MS.actorFollowScores = 1000
SCHEDULER_INTERVALS_MS.removeOldJobs = 10000
SCHEDULER_INTERVALS_MS.updateVideos = 5000
- REPEAT_JOBS['videos-views'] = { every: 5000 }
+ REPEAT_JOBS[ 'videos-views' ] = { every: 5000 }
REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
VIDEO_VIEW_LIFETIME = 1000 // 1 second
CONTACT_FORM_LIFETIME = 1000 // 1 second
- JOB_ATTEMPTS['email'] = 1
+ JOB_ATTEMPTS[ 'email' ] = 1
FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000
MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1
updateWebserverUrls()
+registerConfigChangedHandler(() => {
+ updateWebserverUrls()
+ updateWebserverConfig()
+})
+
// ---------------------------------------------------------------------------
export {
+ WEBSERVER,
API_VERSION,
HLS_REDUNDANCY_DIRECTORY,
P2P_MEDIA_LOADER_PEER_VERSION,
BCRYPT_SALT_SIZE,
TRACKER_RATE_LIMITS,
FILES_CACHE,
- CONFIG,
CONSTRAINTS_FIELDS,
EMBED_SIZE,
REDUNDANCY,
// ---------------------------------------------------------------------------
-function getLocalConfigFilePath () {
- const configSources = config.util.getConfigSources()
- if (configSources.length === 0) throw new Error('Invalid config source.')
-
- let filename = 'local'
- if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}`
- if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}`
-
- return join(dirname(configSources[ 0 ].name), filename + '.json')
-}
-
function buildVideoMimetypeExt () {
const data = {
'video/webm': '.webm',
}
function updateWebserverUrls () {
- CONFIG.WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT)
- CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP)
+ WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT)
+ WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP)
+ WEBSERVER.SCHEME = CONFIG.WEBSERVER.SCHEME
+ WEBSERVER.WS = CONFIG.WEBSERVER.WS
+ WEBSERVER.HOSTNAME = CONFIG.WEBSERVER.HOSTNAME
+ WEBSERVER.PORT = CONFIG.WEBSERVER.PORT
}
function updateWebserverConfig () {
: [ '.mp4', '.ogv', '.webm' ]
}
-function buildVideosRedundancy (objs: any[]): VideosRedundancy[] {
- if (!objs) return []
-
- if (!Array.isArray(objs)) return objs
-
- return objs.map(obj => {
- return Object.assign({}, obj, {
- minLifetime: parseDuration(obj.min_lifetime),
- size: bytes.parse(obj.size),
- minViews: obj.min_views
- })
- })
-}
-
function buildLanguages () {
const iso639 = require('iso-639-3')
iso639
.filter(l => {
return (l.iso6391 !== null && l.type === 'living') ||
- additionalLanguages[l.iso6393] === true
+ additionalLanguages[ l.iso6393 ] === true
})
- .forEach(l => languages[l.iso6391 || l.iso6393] = l.name)
+ .forEach(l => languages[ l.iso6391 || l.iso6393 ] = l.name)
// Override Occitan label
- languages['oc'] = 'Occitan'
+ languages[ 'oc' ] = 'Occitan'
return languages
}
-
-export function reloadConfig () {
-
- function directory () {
- if (process.env.NODE_CONFIG_DIR) {
- return process.env.NODE_CONFIG_DIR
- }
-
- return join(root(), 'config')
- }
-
- function purge () {
- for (const fileName in require.cache) {
- if (-1 === fileName.indexOf(directory())) {
- continue
- }
-
- delete require.cache[fileName]
- }
-
- delete require.cache[require.resolve('config')]
- }
-
- purge()
-
- config = require('config')
-
- updateWebserverConfig()
- updateWebserverUrls()
-}
import { VideoFileModel } from '../models/video/video-file'
import { VideoShareModel } from '../models/video/video-share'
import { VideoTagModel } from '../models/video/video-tag'
-import { CONFIG } from './constants'
+import { CONFIG } from './config'
import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update'
import { VideoCaptionModel } from '../models/video/video-caption'
import { VideoImportModel } from '../models/video/video-import'
import { ApplicationModel } from '../models/application/application'
import { OAuthClientModel } from '../models/oauth/oauth-client'
import { applicationExist, clientsExist, usersExist } from './checker-after-init'
-import { FILES_CACHE, CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants'
+import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants'
import { sequelizeTypescript } from './database'
-import { remove, ensureDir } from 'fs-extra'
+import { ensureDir, remove } from 'fs-extra'
+import { CONFIG } from './config'
async function installApplication () {
try {
import * as Sequelize from 'sequelize'
import { join } from 'path'
-import { CONFIG } from '../../initializers/constants'
+import { CONFIG } from '../../initializers/config'
import { getVideoFileResolution } from '../../helpers/ffmpeg-utils'
import { readdir, rename } from 'fs-extra'
import * as Sequelize from 'sequelize'
-import { CONFIG } from '../constants'
+import { WEBSERVER } from '../constants'
async function up (utils: {
transaction: Sequelize.Transaction,
queryInterface: Sequelize.QueryInterface,
sequelize: Sequelize.Sequelize
}): Promise<void> {
- const toReplace = CONFIG.WEBSERVER.HOSTNAME + ':443'
- const by = CONFIG.WEBSERVER.HOST
+ const toReplace = WEBSERVER.HOSTNAME + ':443'
+ const by = WEBSERVER.HOST
const replacer = column => `replace("${column}", '${toReplace}', '${by}')`
{
import * as Sequelize from 'sequelize'
-import { createClient } from 'redis'
-import { CONFIG } from '../constants'
-import { JobQueue } from '../../lib/job-queue'
-import { initDatabaseModels } from '../database'
async function up (utils: {
transaction: Sequelize.Transaction
import * as Sequelize from 'sequelize'
-import { createClient } from 'redis'
-import { CONFIG } from '../constants'
-import { JobQueue } from '../../lib/job-queue'
-import { initDatabaseModels } from '../database'
async function up (utils: {
transaction: Sequelize.Transaction
import * as Sequelize from 'sequelize'
-import { CONFIG } from '../constants'
import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos'
import * as uuidv4 from 'uuid/v4'
+import { WEBSERVER } from '../constants'
async function up (utils: {
transaction: Sequelize.Transaction,
for (const username of usernames) {
const uuid = uuidv4()
- const baseUrl = CONFIG.WEBSERVER.URL + '/video-playlists/' + uuid
+ const baseUrl = WEBSERVER.URL + '/video-playlists/' + uuid
const query = `
INSERT INTO "videoPlaylist" ("url", "uuid", "name", "privacy", "type", "ownerAccountId", "createdAt", "updatedAt")
SELECT '${baseUrl}' AS "url",
import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto'
import { doRequest, downloadImage } from '../../helpers/requests'
import { getUrlFromWebfinger } from '../../helpers/webfinger'
-import { AVATARS_SIZE, CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers'
+import { AVATARS_SIZE, MIMETYPES, sequelizeTypescript, WEBSERVER } from '../../initializers'
import { AccountModel } from '../../models/account/account'
import { ActorModel } from '../../models/activitypub/actor'
import { AvatarModel } from '../../models/avatar/avatar'
import { JobQueue } from '../job-queue'
import { getServerActor } from '../../helpers/utils'
import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor'
+import { CONFIG } from '../../initializers/config'
// Set account keys, this could be long so process after the account creation and do not block the client
function setAsyncActorKeys (actor: ActorModel) {
followingCount: 0,
inboxUrl: url + '/inbox',
outboxUrl: url + '/outbox',
- sharedInboxUrl: CONFIG.WEBSERVER.URL + '/inbox',
+ sharedInboxUrl: WEBSERVER.URL + '/inbox',
followersUrl: url + '/followers',
followingUrl: url + '/following'
})
import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'
import { crawlCollectionPage } from './crawl'
-import { ACTIVITY_PUB, CONFIG, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers'
+import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers'
import { AccountModel } from '../../models/account/account'
import { isArray } from '../../helpers/custom-validators/misc'
import { getOrCreateActorAndServerAndModel } from './actor'
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'
function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: AccountModel, to: string[]) {
const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPlaylistPrivacy.PUBLIC : VideoPlaylistPrivacy.UNLISTED
import { ActivityFollow } from '../../../../shared/models/activitypub'
import { retryTransactionWrapper } from '../../../helpers/database-utils'
import { logger } from '../../../helpers/logger'
-import { sequelizeTypescript, CONFIG } from '../../../initializers'
+import { sequelizeTypescript } from '../../../initializers'
import { ActorModel } from '../../../models/activitypub/actor'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { sendAccept, sendReject } from '../send'
import { Notifier } from '../../notifier'
import { getAPId } from '../../../helpers/activitypub'
import { getServerActor } from '../../../helpers/utils'
+import { CONFIG } from '../../../initializers/config'
async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) {
const activityObject = getAPId(activity.object)
-import { CONFIG } from '../../initializers'
+import { WEBSERVER } from '../../initializers'
import { ActorModel } from '../../models/activitypub/actor'
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
import { VideoModel } from '../../models/video/video'
import { VideoPlaylistModel } from '../../models/video/video-playlist'
function getVideoActivityPubUrl (video: VideoModel) {
- return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
+ return WEBSERVER.URL + '/videos/watch/' + video.uuid
}
function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) {
- return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
+ return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
}
function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) {
- return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid
+ return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid
}
function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
- return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
+ return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
}
function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) {
- return `${CONFIG.WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
+ return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
}
function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
- return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
+ return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
}
function getVideoChannelActivityPubUrl (videoChannelName: string) {
- return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName
+ return WEBSERVER.URL + '/video-channels/' + videoChannelName
}
function getAccountActivityPubUrl (accountName: string) {
- return CONFIG.WEBSERVER.URL + '/accounts/' + accountName
+ return WEBSERVER.URL + '/accounts/' + accountName
}
function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
- return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
+ return WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
}
function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
import { doRequest, downloadImage } from '../../helpers/requests'
import {
ACTIVITY_PUB,
- CONFIG,
MIMETYPES,
P2P_MEDIA_LOADER_PEER_VERSION,
REMOTE_SCHEME,
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'
async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) {
// If the video is not private and is published, we federate it
import 'multer'
import { sendUpdateActor } from './activitypub/send'
-import { AVATARS_SIZE, CONFIG, sequelizeTypescript } from '../initializers'
+import { AVATARS_SIZE, sequelizeTypescript } from '../initializers'
import { updateActorAvatarInstance } from './activitypub'
import { processImage } from '../helpers/image-utils'
import { AccountModel } from '../models/account/account'
import { extname, join } from 'path'
import { retryTransactionWrapper } from '../helpers/database-utils'
import * as uuidv4 from 'uuid/v4'
+import { CONFIG } from '../initializers/config'
async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) {
const extension = extname(avatarPhysicalFile.filename)
import * as express from 'express'
import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n'
-import { CONFIG, CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE } from '../initializers'
+import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, WEBSERVER } from '../initializers'
import { join } from 'path'
import { escapeHTML } from '../helpers/core-utils'
import { VideoModel } from '../models/video/video'
import { AccountModel } from '../models/account/account'
import { VideoChannelModel } from '../models/video/video-channel'
import * as Bluebird from 'bluebird'
+import { CONFIG } from '../initializers/config'
export class ClientHtml {
// Save locale in cookies
res.cookie('clientLanguage', lang, {
- secure: CONFIG.WEBSERVER.SCHEME === 'https',
+ secure: WEBSERVER.SCHEME === 'https',
sameSite: true,
maxAge: 1000 * 3600 * 24 * 90 // 3 months
})
}
private static addVideoOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
- const previewUrl = CONFIG.WEBSERVER.URL + video.getPreviewStaticPath()
- const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath()
+ const previewUrl = WEBSERVER.URL + video.getPreviewStaticPath()
+ const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
const videoNameEscaped = escapeHTML(video.name)
const videoDescriptionEscaped = escapeHTML(video.description)
- const embedUrl = CONFIG.WEBSERVER.URL + video.getEmbedStaticPath()
+ const embedUrl = WEBSERVER.URL + video.getEmbedStaticPath()
const openGraphMetaTags = {
'og:type': 'video',
const oembedLinkTags = [
{
type: 'application/json+oembed',
- href: CONFIG.WEBSERVER.URL + '/services/oembed?url=' + encodeURIComponent(videoUrl),
+ href: WEBSERVER.URL + '/services/oembed?url=' + encodeURIComponent(videoUrl),
title: videoNameEscaped
}
]
import { createTransport, Transporter } from 'nodemailer'
import { isTestInstance } from '../helpers/core-utils'
import { bunyanLogger, logger } from '../helpers/logger'
-import { CONFIG } from '../initializers'
+import { CONFIG } from '../initializers/config'
import { UserModel } from '../models/account/user'
import { VideoModel } from '../models/video/video'
import { JobQueue } from './job-queue'
import { VideoBlacklistModel } from '../models/video/video-blacklist'
import { VideoImportModel } from '../models/video/video-import'
import { ActorFollowModel } from '../models/activitypub/actor-follow'
+import { WEBSERVER } from '../initializers/constants'
type SendEmailOptions = {
to: string[]
addNewVideoFromSubscriberNotification (to: string[], video: VideoModel) {
const channelName = video.VideoChannel.getDisplayName()
- const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath()
+ const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
const text = `Hi dear user,\n\n` +
`Your subscription ${channelName} just published a new video: ${video.name}` +
}
myVideoPublishedNotification (to: string[], video: VideoModel) {
- const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath()
+ const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
const text = `Hi dear user,\n\n` +
`Your video ${video.name} has been published.` +
}
myVideoImportSuccessNotification (to: string[], videoImport: VideoImportModel) {
- const videoUrl = CONFIG.WEBSERVER.URL + videoImport.Video.getWatchStaticPath()
+ const videoUrl = WEBSERVER.URL + videoImport.Video.getWatchStaticPath()
const text = `Hi dear user,\n\n` +
`Your video import ${videoImport.getTargetIdentifier()} is finished.` +
}
myVideoImportErrorNotification (to: string[], videoImport: VideoImportModel) {
- const importUrl = CONFIG.WEBSERVER.URL + '/my-account/video-imports'
+ const importUrl = WEBSERVER.URL + '/my-account/video-imports'
const text = `Hi dear user,\n\n` +
`Your video import ${videoImport.getTargetIdentifier()} encountered an error.` +
addNewCommentOnMyVideoNotification (to: string[], comment: VideoCommentModel) {
const accountName = comment.Account.getDisplayName()
const video = comment.Video
- const commentUrl = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath()
+ const commentUrl = WEBSERVER.URL + comment.getCommentStaticPath()
const text = `Hi dear user,\n\n` +
`A new comment has been posted by ${accountName} on your video ${video.name}` +
addNewCommentMentionNotification (to: string[], comment: VideoCommentModel) {
const accountName = comment.Account.getDisplayName()
const video = comment.Video
- const commentUrl = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath()
+ const commentUrl = WEBSERVER.URL + comment.getCommentStaticPath()
const text = `Hi dear user,\n\n` +
`${accountName} mentioned you on video ${video.name}` +
}
addVideoAbuseModeratorsNotification (to: string[], videoAbuse: VideoAbuseModel) {
- const videoUrl = CONFIG.WEBSERVER.URL + videoAbuse.Video.getWatchStaticPath()
+ const videoUrl = WEBSERVER.URL + videoAbuse.Video.getWatchStaticPath()
const text = `Hi,\n\n` +
- `${CONFIG.WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` +
+ `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` +
`Cheers,\n` +
`PeerTube.`
}
addVideoAutoBlacklistModeratorsNotification (to: string[], video: VideoModel) {
- const VIDEO_AUTO_BLACKLIST_URL = CONFIG.WEBSERVER.URL + '/admin/moderation/video-auto-blacklist/list'
- const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath()
+ const VIDEO_AUTO_BLACKLIST_URL = WEBSERVER.URL + '/admin/moderation/video-auto-blacklist/list'
+ const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
const text = `Hi,\n\n` +
`A recently added video was auto-blacklisted and requires moderator review before publishing.` +
addNewUserRegistrationNotification (to: string[], user: UserModel) {
const text = `Hi,\n\n` +
- `User ${user.username} just registered on ${CONFIG.WEBSERVER.HOST} PeerTube instance.\n\n` +
+ `User ${user.username} just registered on ${WEBSERVER.HOST} PeerTube instance.\n\n` +
`Cheers,\n` +
`PeerTube.`
const emailPayload: EmailPayload = {
to,
- subject: '[PeerTube] New user registration on ' + CONFIG.WEBSERVER.HOST,
+ subject: '[PeerTube] New user registration on ' + WEBSERVER.HOST,
text
}
addVideoBlacklistNotification (to: string[], videoBlacklist: VideoBlacklistModel) {
const videoName = videoBlacklist.Video.name
- const videoUrl = CONFIG.WEBSERVER.URL + videoBlacklist.Video.getWatchStaticPath()
+ const videoUrl = WEBSERVER.URL + videoBlacklist.Video.getWatchStaticPath()
const reasonString = videoBlacklist.reason ? ` for the following reason: ${videoBlacklist.reason}` : ''
- const blockedString = `Your video ${videoName} (${videoUrl} on ${CONFIG.WEBSERVER.HOST} has been blacklisted${reasonString}.`
+ const blockedString = `Your video ${videoName} (${videoUrl} on ${WEBSERVER.HOST} has been blacklisted${reasonString}.`
const text = 'Hi,\n\n' +
blockedString +
}
addVideoUnblacklistNotification (to: string[], video: VideoModel) {
- const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath()
+ const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
const text = 'Hi,\n\n' +
- `Your video ${video.name} (${videoUrl}) on ${CONFIG.WEBSERVER.HOST} has been unblacklisted.` +
+ `Your video ${video.name} (${videoUrl}) on ${WEBSERVER.HOST} has been unblacklisted.` +
'\n\n' +
'Cheers,\n' +
`PeerTube.`
addPasswordResetEmailJob (to: string, resetPasswordUrl: string) {
const text = `Hi dear user,\n\n` +
- `A reset password procedure for your account ${to} has been requested on ${CONFIG.WEBSERVER.HOST} ` +
+ `A reset password procedure for your account ${to} has been requested on ${WEBSERVER.HOST} ` +
`Please follow this link to reset it: ${resetPasswordUrl}\n\n` +
`If you are not the person who initiated this request, please ignore this email.\n\n` +
`Cheers,\n` +
addVerifyEmailJob (to: string, verifyEmailUrl: string) {
const text = `Welcome to PeerTube,\n\n` +
- `To start using PeerTube on ${CONFIG.WEBSERVER.HOST} you must verify your email! ` +
+ `To start using PeerTube on ${WEBSERVER.HOST} you must verify your email! ` +
`Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` +
`If you are not the person who initiated this request, please ignore this email.\n\n` +
`Cheers,\n` +
addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) {
const reasonString = reason ? ` for the following reason: ${reason}` : ''
const blockedWord = blocked ? 'blocked' : 'unblocked'
- const blockedString = `Your account ${user.username} on ${CONFIG.WEBSERVER.HOST} has been ${blockedWord}${reasonString}.`
+ const blockedString = `Your account ${user.username} on ${WEBSERVER.HOST} has been ${blockedWord}${reasonString}.`
const text = 'Hi,\n\n' +
blockedString +
const fromDisplayName = options.fromDisplayName
? options.fromDisplayName
- : CONFIG.WEBSERVER.HOST
+ : WEBSERVER.HOST
return this.transporter.sendMail({
from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`,
import { join } from 'path'
-import { FILES_CACHE, CONFIG } from '../../initializers'
+import { FILES_CACHE } from '../../initializers'
import { VideoModel } from '../../models/video/video'
import { VideoCaptionModel } from '../../models/video/video-caption'
import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache'
+import { CONFIG } from '../../initializers/config'
type GetPathParam = { videoId: string, language: string }
import { join } from 'path'
-import { FILES_CACHE, CONFIG, STATIC_PATHS } from '../../initializers'
+import { FILES_CACHE, STATIC_PATHS } from '../../initializers'
import { VideoModel } from '../../models/video/video'
import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache'
+import { CONFIG } from '../../initializers/config'
class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
import { VideoModel } from '../models/video/video'
import { basename, dirname, join } from 'path'
-import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers'
+import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers'
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'
import { generateRandomString } from '../helpers/utils'
import { flatten, uniq } from 'lodash'
import { VideoFileModel } from '../models/video/video-file'
+import { CONFIG } from '../initializers/config'
async function updateStreamingPlaylistsInfohashesIfNeeded () {
const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion()
import * as Bull from 'bull'
import { logger } from '../../../helpers/logger'
-import { CONFIG, REMOTE_SCHEME, sequelizeTypescript } from '../../../initializers'
+import { REMOTE_SCHEME, sequelizeTypescript, WEBSERVER } from '../../../initializers'
import { sendFollow } from '../../activitypub/send'
import { sanitizeHost } from '../../../helpers/core-utils'
import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger'
logger.info('Processing ActivityPub follow in job %d.', job.id)
let targetActor: ActorModel
- if (!host || host === CONFIG.WEBSERVER.HOST) {
+ if (!host || host === WEBSERVER.HOST) {
targetActor = await ActorModel.loadLocalByName(payload.name)
} else {
const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP)
import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
import { extname, join } from 'path'
import { VideoFileModel } from '../../../models/video/video-file'
-import { CONFIG, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers'
+import { PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers'
import { downloadImage } from '../../../helpers/requests'
import { VideoState } from '../../../../shared'
import { JobQueue } from '../index'
import { VideoModel } from '../../../models/video/video'
import { downloadWebTorrentVideo } from '../../../helpers/webtorrent'
import { getSecureTorrentName } from '../../../helpers/utils'
-import { remove, move, stat } from 'fs-extra'
+import { move, remove, stat } from 'fs-extra'
import { Notifier } from '../../notifier'
+import { CONFIG } from '../../../initializers/config'
type VideoImportYoutubeDLPayload = {
type: 'youtube-dl'
import { JobQueue } from '../job-queue'
import { federateVideoIfNeeded } from '../../activitypub'
import { retryTransactionWrapper } from '../../../helpers/database-utils'
-import { CONFIG, sequelizeTypescript } from '../../../initializers'
+import { sequelizeTypescript } from '../../../initializers'
import * as Bluebird from 'bluebird'
import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils'
import { generateHlsPlaylist, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding'
import { Notifier } from '../../notifier'
+import { CONFIG } from '../../../initializers/config'
export type VideoTranscodingPayload = {
videoUUID: string
import { JobState, JobType } from '../../../shared/models'
import { logger } from '../../helpers/logger'
import { Redis } from '../redis'
-import { CONFIG, JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS } from '../../initializers'
+import { JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers'
import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast'
import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher'
import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast'
if (this.initialized === true) return
this.initialized = true
- this.jobRedisPrefix = 'bull-' + CONFIG.WEBSERVER.HOST
+ this.jobRedisPrefix = 'bull-' + WEBSERVER.HOST
const queueOptions = {
prefix: this.jobRedisPrefix,
redis: Redis.getRedisClient(),
import { VideoCommentModel } from '../models/video/video-comment'
import { UserModel } from '../models/account/user'
import { PeerTubeSocket } from './peertube-socket'
-import { CONFIG } from '../initializers/constants'
+import { CONFIG } from '../initializers/config'
import { VideoPrivacy, VideoState } from '../../shared/models/videos'
import { VideoAbuseModel } from '../models/video/video-abuse'
import { VideoBlacklistModel } from '../models/video/video-blacklist'
import { UserModel } from '../models/account/user'
import { OAuthClientModel } from '../models/oauth/oauth-client'
import { OAuthTokenModel } from '../models/oauth/oauth-token'
-import { CONFIG, CACHE } from '../initializers/constants'
+import { CACHE } from '../initializers/constants'
import { Transaction } from 'sequelize'
+import { CONFIG } from '../initializers/config'
type TokenInfo = { accessToken: string, refreshToken: string, accessTokenExpiresAt: Date, refreshTokenExpiresAt: Date }
let accessTokenCache: { [ accessToken: string ]: OAuthTokenModel } = {}
import { logger } from '../helpers/logger'
import { generateRandomString } from '../helpers/utils'
import {
- CONFIG,
CONTACT_FORM_LIFETIME,
USER_EMAIL_VERIFY_LIFETIME,
USER_PASSWORD_RESET_LIFETIME,
- VIDEO_VIEW_LIFETIME
+ VIDEO_VIEW_LIFETIME,
+ WEBSERVER
} from '../initializers'
+import { CONFIG } from '../initializers/config'
type CachedRoute = {
body: string,
this.client.auth(CONFIG.REDIS.AUTH)
}
- this.prefix = 'redis-' + CONFIG.WEBSERVER.HOST + '-'
+ this.prefix = 'redis-' + WEBSERVER.HOST + '-'
}
static getRedisClient () {
import { AbstractScheduler } from './abstract-scheduler'
-import { CONFIG, HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers'
+import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT, WEBSERVER } from '../../initializers'
import { logger } from '../../helpers/logger'
import { VideosRedundancy } from '../../../shared/models/redundancy'
import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
import { VideoModel } from '../../models/video/video'
import { downloadPlaylistSegments } from '../hls'
+import { CONFIG } from '../../initializers/config'
type CandidateToDuplicate = {
redundancy: VideosRedundancy,
const createdModel = await VideoRedundancyModel.create({
expiresOn: this.buildNewExpiration(redundancy.minLifetime),
url: getVideoCacheFileActivityPubUrl(file),
- fileUrl: video.getVideoRedundancyUrl(file, CONFIG.WEBSERVER.URL),
+ fileUrl: video.getVideoRedundancyUrl(file, WEBSERVER.URL),
strategy: redundancy.strategy,
videoFileId: file.id,
actorId: serverActor.id
const createdModel = await VideoRedundancyModel.create({
expiresOn: this.buildNewExpiration(redundancy.minLifetime),
url: getVideoCacheStreamingPlaylistActivityPubUrl(video, playlist),
- fileUrl: playlist.getVideoRedundancyUrl(CONFIG.WEBSERVER.URL),
+ fileUrl: playlist.getVideoRedundancyUrl(WEBSERVER.URL),
strategy: redundancy.strategy,
videoStreamingPlaylistId: playlist.id,
actorId: serverActor.id
import * as sequelize from 'sequelize'
-import { CONFIG } from '../initializers/constants'
+import { CONFIG } from '../initializers/config'
import { VideoBlacklistType, UserRight } from '../../shared/models'
import { VideoBlacklistModel } from '../models/video/video-blacklist'
import { UserModel } from '../models/account/user'
-import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION } from '../initializers'
+import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers'
import { join } from 'path'
import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils'
import { ensureDir, move, remove, stat } from 'fs-extra'
import { updateMasterHLSPlaylist, updateSha256Segments } from './hls'
import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type'
+import { CONFIG } from '../initializers/config'
async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) {
const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR
await updateMasterHLSPlaylist(video)
await updateSha256Segments(video)
- const playlistUrl = CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid)
+ const playlistUrl = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid)
await VideoStreamingPlaylistModel.upsert({
videoId: video.id,
playlistUrl,
- segmentsSha256Url: CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid),
+ segmentsSha256Url: WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid),
p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, video.VideoFiles),
p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION,
import * as helmet from 'helmet'
-import { CONFIG } from '../initializers/constants'
+import { CONFIG } from '../initializers/config'
const baseDirectives = Object.assign({},
{
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
-import { UserModel } from '../../models/account/user'
import { AccountBlocklistModel } from '../../models/account/account-blocklist'
import { isHostValid } from '../../helpers/custom-validators/servers'
import { ServerBlocklistModel } from '../../models/server/server-blocklist'
import { ServerModel } from '../../models/server/server'
-import { CONFIG } from '../../initializers'
import { getServerActor } from '../../helpers/utils'
+import { WEBSERVER } from '../../initializers/constants'
const blockAccountValidator = [
body('accountName').exists().withMessage('Should have an account name with host'),
const host: string = req.body.host
- if (host === CONFIG.WEBSERVER.HOST) {
+ if (host === WEBSERVER.HOST) {
return res.status(409)
.send({ error: 'You cannot block your own server.' })
.end()
import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
import { logger } from '../../helpers/logger'
import { getServerActor } from '../../helpers/utils'
-import { CONFIG, SERVER_ACTOR_NAME } from '../../initializers'
+import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers'
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
import { areValidationErrors } from './utils'
import { ActorModel } from '../../models/activitypub/actor'
(req: express.Request, res: express.Response, next: express.NextFunction) => {
// Force https if the administrator wants to make friends
- if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') {
+ if (isTestInstance() === false && WEBSERVER.SCHEME === 'http') {
return res.status(500)
.json({
error: 'Cannot follow on a non HTTPS web server.'
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
import { doesVideoExist } from '../../helpers/custom-validators/videos'
import { logger } from '../../helpers/logger'
-import { CONFIG } from '../../initializers'
import { areValidationErrors } from './utils'
+import { WEBSERVER } from '../../initializers/constants'
-const urlShouldStartWith = CONFIG.WEBSERVER.SCHEME + '://' + join(CONFIG.WEBSERVER.HOST, 'videos', 'watch') + '/'
+const urlShouldStartWith = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch') + '/'
const videoWatchRegex = new RegExp('([^/]+)$')
const isURLOptions = {
require_host: true,
import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
import { Emailer } from '../../lib/emailer'
import { Redis } from '../../lib/redis'
-import { CONFIG } from '../../initializers/constants'
+import { CONFIG } from '../../initializers/config'
const serverGetValidator = [
body('host').custom(isHostValid).withMessage('Should have a valid host'),
import { areValidationErrors } from './utils'
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
-import { CONFIG } from '../../initializers'
import { toArray } from '../../helpers/custom-validators/misc'
+import { WEBSERVER } from '../../initializers/constants'
const userSubscriptionAddValidator = [
body('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),
if (areValidationErrors(req, res)) return
let [ name, host ] = req.params.uri.split('@')
- if (host === CONFIG.WEBSERVER.HOST) host = null
+ if (host === WEBSERVER.HOST) host = null
const user = res.locals.oauth.token.User
const subscription = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI(user.Account.Actor.id, name, host)
import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports'
import { cleanUpReqFiles } from '../../../helpers/express-utils'
import { doesVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos'
-import { CONFIG } from '../../../initializers/constants'
+import { CONFIG } from '../../../initializers/config'
import { CONSTRAINTS_FIELDS } from '../../../initializers'
const videoImportAddValidator = getCommonVideoEditAttributes().concat([
} from '../../../helpers/custom-validators/videos'
import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils'
import { logger } from '../../../helpers/logger'
-import { CONFIG, CONSTRAINTS_FIELDS } from '../../../initializers'
+import { CONSTRAINTS_FIELDS } from '../../../initializers'
import { authenticatePromiseIfNeeded } from '../../oauth'
import { areValidationErrors } from '../utils'
import { cleanUpReqFiles } from '../../../helpers/express-utils'
import { VideoFetchType } from '../../../helpers/video'
import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search'
import { getServerActor } from '../../../helpers/utils'
+import { CONFIG } from '../../../initializers/config'
const videosAddValidator = getCommonVideoEditAttributes().concat([
body('videofile')
import { VideoChannelModel } from '../video/video-channel'
import { VideoCommentModel } from '../video/video-comment'
import { UserModel } from './user'
-import { CONFIG } from '../../initializers'
import { AvatarModel } from '../avatar/avatar'
import { VideoPlaylistModel } from '../video/video-playlist'
+import { WEBSERVER } from '../../initializers/constants'
export enum ScopeNames {
SUMMARY = 'SUMMARY'
static loadByNameWithHost (nameWithHost: string) {
const [ accountName, host ] = nameWithHost.split('@')
- if (!host || host === CONFIG.WEBSERVER.HOST) return AccountModel.loadLocalByName(accountName)
+ if (!host || host === WEBSERVER.HOST) return AccountModel.loadLocalByName(accountName)
return AccountModel.loadByNameAndHost(accountName, host)
}
isActorPublicKeyValid
} from '../../helpers/custom-validators/activitypub/actor'
import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
-import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONFIG, CONSTRAINTS_FIELDS } from '../../initializers'
+import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers'
import { AccountModel } from '../account/account'
import { AvatarModel } from '../avatar/avatar'
import { ServerModel } from '../server/server'
}
getHost () {
- return this.Server ? this.Server.host : CONFIG.WEBSERVER.HOST
+ return this.Server ? this.Server.host : WEBSERVER.HOST
}
getRedundancyAllowed () {
getAvatarUrl () {
if (!this.avatarId) return undefined
- return CONFIG.WEBSERVER.URL + this.Avatar.getWebserverPath()
+ return WEBSERVER.URL + this.Avatar.getWebserverPath()
}
isOutdated () {
import { join } from 'path'
import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript'
import { Avatar } from '../../../shared/models/avatars/avatar.model'
-import { CONFIG, STATIC_PATHS } from '../../initializers'
+import { STATIC_PATHS } from '../../initializers'
import { logger } from '../../helpers/logger'
import { remove } from 'fs-extra'
+import { CONFIG } from '../../initializers/config'
@Table({
tableName: 'avatar'
import { ActorModel } from '../activitypub/actor'
import { getVideoSort, throwIfNotValid } from '../utils'
import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc'
-import { CONFIG, CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers'
+import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers'
import { VideoFileModel } from '../video/video-file'
import { getServerActor } from '../../helpers/utils'
import { VideoModel } from '../video/video'
import * as Bluebird from 'bluebird'
import * as Sequelize from 'sequelize'
import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist'
+import { CONFIG } from '../../initializers/config'
export enum ScopeNames {
WITH_VIDEO = 'WITH_VIDEO'
import { VideoModel } from './video'
import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'
import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'
-import { CONFIG, STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers'
+import { STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers'
import { join } from 'path'
import { logger } from '../../helpers/logger'
import { remove } from 'fs-extra'
+import { CONFIG } from '../../initializers/config'
export enum ScopeNames {
WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE'
Default,
DefaultScope,
ForeignKey,
- HasMany, IFindOptions,
+ HasMany,
+ IFindOptions,
Is,
Model,
Scopes,
import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor'
import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils'
import { VideoModel } from './video'
-import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers'
+import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers'
import { ServerModel } from '../server/server'
import { DefineIndexesOptions } from 'sequelize'
import { AvatarModel } from '../avatar/avatar'
static loadByNameWithHostAndPopulateAccount (nameWithHost: string) {
const [ name, host ] = nameWithHost.split('@')
- if (!host || host === CONFIG.WEBSERVER.HOST) return VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
+ if (!host || host === WEBSERVER.HOST) return VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host)
}
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 { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers'
+import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers'
import { sendDeleteVideoComment } from '../../lib/activitypub/send'
import { AccountModel } from '../account/account'
import { ActorModel } from '../activitypub/actor'
let result: string[] = []
const localMention = `@(${actorNameAlphabet}+)`
- const remoteMention = `${localMention}@${CONFIG.WEBSERVER.HOST}`
+ const remoteMention = `${localMention}@${WEBSERVER.HOST}`
const mentionRegex = this.isOwned()
? '(?:(?:' + remoteMention + ')|(?:' + localMention + '))' // Include local mentions?
ActivityUrlObject,
VideoTorrentObject
} from '../../../shared/models/activitypub/objects'
-import { CONFIG, MIMETYPES, THUMBNAILS_SIZE } from '../../initializers'
+import { MIMETYPES, THUMBNAILS_SIZE, WEBSERVER } from '../../initializers'
import { VideoCaptionModel } from './video-caption'
import {
getVideoCommentsActivityPubUrl,
type: 'Link',
mimeType: 'text/html',
mediaType: 'text/html',
- href: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
+ href: WEBSERVER.URL + '/videos/watch/' + video.uuid
})
const subtitleLanguage = []
import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
import {
ACTIVITY_PUB,
- CONFIG,
CONSTRAINTS_FIELDS,
STATIC_PATHS,
THUMBNAILS_SIZE,
VIDEO_PLAYLIST_PRIVACIES,
- VIDEO_PLAYLIST_TYPES
+ VIDEO_PLAYLIST_TYPES,
+ WEBSERVER
} from '../../initializers'
import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model'
import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account'
import { remove } from 'fs-extra'
import { logger } from '../../helpers/logger'
import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model'
+import { CONFIG } from '../../initializers/config'
enum ScopeNames {
AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST',
}
getThumbnailUrl () {
- return CONFIG.WEBSERVER.URL + STATIC_PATHS.THUMBNAILS + this.getThumbnailName()
+ return WEBSERVER.URL + STATIC_PATHS.THUMBNAILS + this.getThumbnailName()
}
getThumbnailStaticPath () {
import {
ACTIVITY_PUB,
API_VERSION,
- CONFIG,
CONSTRAINTS_FIELDS,
- HLS_STREAMING_PLAYLIST_DIRECTORY,
HLS_REDUNDANCY_DIRECTORY,
+ HLS_STREAMING_PLAYLIST_DIRECTORY,
PREVIEWS_SIZE,
REMOTE_SCHEME,
STATIC_DOWNLOAD_PATHS,
VIDEO_LANGUAGES,
VIDEO_LICENCES,
VIDEO_PRIVACIES,
- VIDEO_STATES
+ VIDEO_STATES,
+ WEBSERVER
} from '../../initializers'
import { sendDeleteVideo } from '../../lib/activitypub/send'
import { AccountModel } from '../account/account'
buildTrigramSearchIndex,
buildWhereIdOrUUID,
createSimilarityAttribute,
- getVideoSort, isOutdated,
+ getVideoSort,
+ isOutdated,
throwIfNotValid
} from '../utils'
import { TagModel } from './tag'
import { VideoAbuseModel } from './video-abuse'
-import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel'
+import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel'
import { VideoCommentModel } from './video-comment'
import { VideoFileModel } from './video-file'
import { VideoShareModel } from './video-share'
import { VideoImportModel } from './video-import'
import { VideoStreamingPlaylistModel } from './video-streaming-playlist'
import { VideoPlaylistElementModel } from './video-playlist-element'
+import { CONFIG } from '../../initializers/config'
// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation
const indexes: Sequelize.DefineIndexesOptions[] = [
name: `${this.name} ${videoFile.resolution}p${videoFile.extname}`,
createdBy: 'PeerTube',
announceList: [
- [ CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT + '/tracker/socket' ],
- [ CONFIG.WEBSERVER.URL + '/tracker/announce' ]
+ [ WEBSERVER.WS + '://' + WEBSERVER.HOSTNAME + ':' + WEBSERVER.PORT + '/tracker/socket' ],
+ [ WEBSERVER.URL + '/tracker/announce' ]
],
- urlList: [ CONFIG.WEBSERVER.URL + STATIC_PATHS.WEBSEED + this.getVideoFilename(videoFile) ]
+ urlList: [ WEBSERVER.URL + STATIC_PATHS.WEBSEED + this.getVideoFilename(videoFile) ]
}
const torrent = await createTorrentPromise(this.getVideoFilePath(videoFile), options)
let baseUrlWs
if (this.isOwned()) {
- baseUrlHttp = CONFIG.WEBSERVER.URL
- baseUrlWs = CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
+ baseUrlHttp = WEBSERVER.URL
+ baseUrlWs = WEBSERVER.WS + '://' + WEBSERVER.HOSTNAME + ':' + WEBSERVER.PORT
} else {
baseUrlHttp = REMOTE_SCHEME.HTTP + '://' + this.VideoChannel.Account.Actor.Server.host
baseUrlWs = REMOTE_SCHEME.WS + '://' + this.VideoChannel.Account.Actor.Server.host