mirror of https://github.com/Chocobozzz/PeerTube
/!\ Use a dedicated config file for development
It means you have to replace NODE_ENV=test to NODE_ENV=dev if you use it npm run dev:* commands are already updatedpull/5097/head
parent
630d0a1bf5
commit
9452d4fd33
|
@ -216,7 +216,7 @@ Instance configurations are in `config/test-{1,2,3}.yaml`.
|
|||
To test emails with PeerTube:
|
||||
|
||||
* Run [mailslurper](http://mailslurper.com/)
|
||||
* Run PeerTube using mailslurper SMTP port: `NODE_CONFIG='{ "smtp": { "hostname": "localhost", "port": 2500, "tls": false } }' NODE_ENV=test npm start`
|
||||
* Run PeerTube using mailslurper SMTP port: `NODE_CONFIG='{ "smtp": { "hostname": "localhost", "port": 2500, "tls": false } }' NODE_ENV=dev node dist/server`
|
||||
|
||||
## Plugins & Themes
|
||||
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
listen:
|
||||
hostname: '::'
|
||||
port: 9000
|
||||
|
||||
webserver:
|
||||
https: false
|
||||
|
||||
database:
|
||||
hostname: 'localhost'
|
||||
port: 5432
|
||||
|
||||
redis:
|
||||
hostname: 'localhost'
|
||||
|
||||
smtp:
|
||||
hostname: null
|
||||
port: 1025
|
||||
tls: false
|
||||
disable_starttls: true
|
||||
from_address: 'test-admin@localhost'
|
||||
username: null
|
||||
password: null
|
||||
|
||||
log:
|
||||
level: 'debug'
|
||||
|
||||
contact_form:
|
||||
enabled: true
|
||||
|
||||
peertube:
|
||||
check_latest_version:
|
||||
enabled: false
|
||||
|
||||
redundancy:
|
||||
videos:
|
||||
check_interval: '5 minutes'
|
||||
strategies:
|
||||
-
|
||||
size: '1000MB'
|
||||
min_lifetime: '10 minutes'
|
||||
strategy: 'most-views'
|
||||
-
|
||||
size: '1000MB'
|
||||
min_lifetime: '10 minutes'
|
||||
strategy: 'trending'
|
||||
-
|
||||
size: '1000MB'
|
||||
min_lifetime: '10 minutes'
|
||||
strategy: 'recently-added'
|
||||
min_views: 1
|
||||
|
||||
cache:
|
||||
previews:
|
||||
size: 10
|
||||
captions:
|
||||
size: 10
|
||||
torrents:
|
||||
size: 10
|
||||
|
||||
signup:
|
||||
enabled: true
|
||||
requires_email_verification: false
|
||||
|
||||
live:
|
||||
enabled: true
|
||||
|
||||
allow_replay: true
|
||||
|
||||
transcoding:
|
||||
enabled: true
|
||||
threads: 2
|
||||
|
||||
resolutions:
|
||||
360p: true
|
||||
720p: true
|
||||
|
||||
import:
|
||||
videos:
|
||||
concurrency: 2
|
||||
http:
|
||||
enabled: true
|
||||
torrent:
|
||||
enabled: true
|
||||
|
||||
instance:
|
||||
default_nsfw_policy: 'display'
|
||||
|
||||
plugins:
|
||||
index:
|
||||
check_latest_versions_interval: '10 minutes'
|
||||
|
||||
federation:
|
||||
videos:
|
||||
cleanup_remote_interactions: false
|
||||
|
||||
views:
|
||||
videos:
|
||||
remote:
|
||||
max_age: -1
|
||||
|
||||
geo_ip:
|
||||
enabled: true
|
||||
|
||||
video_studio:
|
||||
enabled: true
|
|
@ -133,28 +133,6 @@ plugins:
|
|||
index:
|
||||
check_latest_versions_interval: '10 minutes'
|
||||
|
||||
search:
|
||||
# Add ability to fetch remote videos/actors by their URI, that may not be federated with your instance
|
||||
# If enabled, the associated group will be able to "escape" from the instance follows
|
||||
# That means they will be able to follow channels, watch videos, list videos of non followed instances
|
||||
remote_uri:
|
||||
users: true
|
||||
anonymous: false
|
||||
|
||||
# Use a third party index instead of your local index, only for search results
|
||||
# Useful to discover content outside of your instance
|
||||
search_index:
|
||||
enabled: false
|
||||
# URL of the search index, that should use the same search API and routes
|
||||
# than PeerTube: https://docs.joinpeertube.org/api-rest-reference.html
|
||||
# You should deploy your own with https://framagit.org/framasoft/peertube/search-index,
|
||||
# and can use https://search.joinpeertube.org/ for tests, but keep in mind the latter is an unmoderated search index
|
||||
url: 'http://localhost:3234'
|
||||
# You can disable local search, so users only use the search index
|
||||
disable_local_search: false
|
||||
# If you did not disable local search, you can decide to use the search index by default
|
||||
is_default_search: true
|
||||
|
||||
federation:
|
||||
videos:
|
||||
federate_unlisted: true
|
||||
|
|
|
@ -9,12 +9,12 @@ if [ ! -z ${2+x} ] && [ "$2" = "--ar-locale" ]; then
|
|||
fi
|
||||
|
||||
clientCommand="cd client && node --max_old_space_size=4096 node_modules/.bin/ng serve --proxy-config proxy.config.json --hmr --configuration $clientConfiguration --host 0.0.0.0 --disable-host-check --port 3000"
|
||||
serverCommand="npm run build:server && NODE_ENV=test node dist/server"
|
||||
serverCommand="npm run build:server && NODE_ENV=dev node dist/server"
|
||||
|
||||
if [ ! -z ${1+x} ] && [ "$1" = "--skip-server" ]; then
|
||||
NODE_ENV=test eval $clientCommand
|
||||
eval $clientCommand
|
||||
else
|
||||
NODE_ENV=test node node_modules/.bin/concurrently -k \
|
||||
node node_modules/.bin/concurrently -k \
|
||||
"$clientCommand" \
|
||||
"$serverCommand"
|
||||
fi
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
set -eu
|
||||
|
||||
NODE_ENV=test npm run concurrently -- -k \
|
||||
npm run concurrently -- -k \
|
||||
"cd client && npm run webpack -- --config webpack/webpack.video-embed.js --mode development --watch" \
|
||||
"npm run build:server && NODE_ENV=test npm start"
|
||||
"npm run build:server && NODE_ENV=dev npm start"
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
set -eu
|
||||
|
||||
NODE_ENV=test npm run concurrently -- -k \
|
||||
npm run concurrently -- -k \
|
||||
"sh scripts/dev/client.sh --skip-server ${1:-}" \
|
||||
"sh scripts/dev/server.sh --skip-client"
|
||||
|
|
|
@ -22,4 +22,4 @@ npm run resolve-tspaths:server
|
|||
cp -r ./server/static ./server/assets ./dist/server
|
||||
cp -r "./server/lib/emails" "./dist/server/lib"
|
||||
|
||||
./node_modules/.bin/tsc-watch --build --preserveWatchOutput --verbose --onSuccess 'sh -c "npm run resolve-tspaths:server && NODE_ENV=test node dist/server"'
|
||||
./node_modules/.bin/tsc-watch --build --preserveWatchOutput --verbose --onSuccess 'sh -c "npm run resolve-tspaths:server && NODE_ENV=dev node dist/server"'
|
||||
|
|
|
@ -134,7 +134,7 @@ import { HttpStatusCode } from './shared/models/http/http-error-codes'
|
|||
import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
|
||||
import { ServerConfigManager } from '@server/lib/server-config-manager'
|
||||
import { VideoViewsManager } from '@server/lib/views/video-views-manager'
|
||||
import { isTestInstance } from './server/helpers/core-utils'
|
||||
import { isTestOrDevInstance } from './server/helpers/core-utils'
|
||||
import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics'
|
||||
|
||||
// ----------- Command line -----------
|
||||
|
@ -148,7 +148,7 @@ cli
|
|||
// ----------- App -----------
|
||||
|
||||
// Enable CORS for develop
|
||||
if (isTestInstance()) {
|
||||
if (isTestOrDevInstance()) {
|
||||
app.use(cors({
|
||||
origin: '*',
|
||||
exposedHeaders: 'Retry-After',
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import express from 'express'
|
||||
import { isTestOrDevInstance } from '@server/helpers/core-utils'
|
||||
import { OAuthClientModel } from '@server/models/oauth/oauth-client'
|
||||
import { HttpStatusCode, OAuthClientLocal } from '@shared/models'
|
||||
import { logger } from '../../helpers/logger'
|
||||
|
@ -22,7 +23,7 @@ async function getLocalClient (req: express.Request, res: express.Response, next
|
|||
}
|
||||
|
||||
// Don't make this check if this is a test instance
|
||||
if (process.env.NODE_ENV !== 'test' && req.get('host') !== headerHostShouldBe) {
|
||||
if (!isTestOrDevInstance() && req.get('host') !== headerHostShouldBe) {
|
||||
logger.info('Getting client tokens for host %s is forbidden (expected %s).', req.get('host'), headerHostShouldBe)
|
||||
return res.fail({
|
||||
status: HttpStatusCode.FORBIDDEN_403,
|
||||
|
|
|
@ -5,7 +5,7 @@ import { optionalAuthenticate } from '@server/middlewares/auth'
|
|||
import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n'
|
||||
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
|
||||
import { PluginType } from '../../shared/models/plugins/plugin.type'
|
||||
import { isTestInstance } from '../helpers/core-utils'
|
||||
import { isProdInstance } from '../helpers/core-utils'
|
||||
import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants'
|
||||
import { PluginManager, RegisteredPlugin } from '../lib/plugins/plugin-manager'
|
||||
import { getExternalAuthValidator, getPluginValidator, pluginStaticDirectoryValidator } from '../middlewares/validators/plugins'
|
||||
|
@ -13,7 +13,7 @@ import { serveThemeCSSValidator } from '../middlewares/validators/themes'
|
|||
|
||||
const sendFileOptions = {
|
||||
maxAge: '30 days',
|
||||
immutable: !isTestInstance()
|
||||
immutable: isProdInstance()
|
||||
}
|
||||
|
||||
const pluginsRouter = express.Router()
|
||||
|
|
|
@ -165,6 +165,14 @@ function isTestInstance () {
|
|||
return process.env.NODE_ENV === 'test'
|
||||
}
|
||||
|
||||
function isDevInstance () {
|
||||
return process.env.NODE_ENV === 'dev'
|
||||
}
|
||||
|
||||
function isTestOrDevInstance () {
|
||||
return isTestInstance() || isDevInstance()
|
||||
}
|
||||
|
||||
function isProdInstance () {
|
||||
return process.env.NODE_ENV === 'production'
|
||||
}
|
||||
|
@ -270,6 +278,7 @@ const pipelinePromise = promisify(pipeline)
|
|||
|
||||
export {
|
||||
isTestInstance,
|
||||
isTestOrDevInstance,
|
||||
isProdInstance,
|
||||
getAppNumber,
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import validator from 'validator'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
|
||||
import { isTestInstance } from '../../core-utils'
|
||||
import { isTestOrDevInstance } from '../../core-utils'
|
||||
import { exists } from '../misc'
|
||||
|
||||
function isUrlValid (url: string) {
|
||||
|
@ -13,7 +13,7 @@ function isUrlValid (url: string) {
|
|||
}
|
||||
|
||||
// We validate 'localhost', so we don't have the top level domain
|
||||
if (isTestInstance()) {
|
||||
if (isTestOrDevInstance()) {
|
||||
isURLOptions.require_tld = false
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import validator from 'validator'
|
||||
import { exists, isArray } from './misc'
|
||||
import { isTestInstance } from '../core-utils'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
import { isTestOrDevInstance } from '../core-utils'
|
||||
import { exists, isArray } from './misc'
|
||||
|
||||
function isHostValid (host: string) {
|
||||
const isURLOptions = {
|
||||
|
@ -10,7 +10,7 @@ function isHostValid (host: string) {
|
|||
}
|
||||
|
||||
// We validate 'localhost', so we don't have the top level domain
|
||||
if (isTestInstance()) {
|
||||
if (isTestOrDevInstance()) {
|
||||
isURLOptions.require_tld = false
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { URL } from 'url'
|
|||
import { getFFmpegVersion } from '@server/helpers/ffmpeg'
|
||||
import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
|
||||
import { RecentlyAddedStrategy } from '../../shared/models/redundancy'
|
||||
import { isProdInstance, isTestInstance, parseSemVersion } from '../helpers/core-utils'
|
||||
import { isProdInstance, parseSemVersion } from '../helpers/core-utils'
|
||||
import { isArray } from '../helpers/custom-validators/misc'
|
||||
import { logger } from '../helpers/logger'
|
||||
import { ApplicationModel, getServerActor } from '../models/application/application'
|
||||
|
@ -34,6 +34,9 @@ async function checkActivityPubUrls () {
|
|||
// Some checks on configuration files or throw if there is an error
|
||||
function checkConfig () {
|
||||
|
||||
const configFiles = config.util.getConfigSources().map(s => s.name).join(' -> ')
|
||||
logger.info('Using following configuration file hierarchy: %s.', configFiles)
|
||||
|
||||
// Moved configuration keys
|
||||
if (config.has('services.csp-logger')) {
|
||||
logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
|
||||
|
@ -128,7 +131,7 @@ function checkLocalRedundancyConfig () {
|
|||
}
|
||||
|
||||
// Lifetime should not be < 10 hours
|
||||
if (!isTestInstance() && r.minLifetime < 1000 * 3600 * 10) {
|
||||
if (isProdInstance() && r.minLifetime < 1000 * 3600 * 10) {
|
||||
throw new Error('Video redundancy minimum lifetime should be >= 10 hours for strategy ' + r.strategy)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
|
|||
import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'
|
||||
import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'
|
||||
// Do not use barrels, remain constants as independent as possible
|
||||
import { isTestInstance, parseDurationToMs, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
|
||||
import { isTestInstance, isTestOrDevInstance, parseDurationToMs, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
|
||||
import { CONFIG, registerConfigChangedHandler } from './config'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -822,57 +822,62 @@ const STATS_TIMESERIE = {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Special constants for a test instance
|
||||
if (isTestInstance() === true && process.env.PRODUCTION_CONSTANTS !== 'true') {
|
||||
PRIVATE_RSA_KEY_SIZE = 1024
|
||||
if (process.env.PRODUCTION_CONSTANTS !== 'true') {
|
||||
if (isTestOrDevInstance()) {
|
||||
PRIVATE_RSA_KEY_SIZE = 1024
|
||||
|
||||
ACTOR_FOLLOW_SCORE.BASE = 20
|
||||
ACTOR_FOLLOW_SCORE.BASE = 20
|
||||
|
||||
REMOTE_SCHEME.HTTP = 'http'
|
||||
REMOTE_SCHEME.WS = 'ws'
|
||||
REMOTE_SCHEME.HTTP = 'http'
|
||||
REMOTE_SCHEME.WS = 'ws'
|
||||
|
||||
STATIC_MAX_AGE.SERVER = '0'
|
||||
STATIC_MAX_AGE.SERVER = '0'
|
||||
|
||||
ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2
|
||||
ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
|
||||
ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
|
||||
ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
|
||||
SCHEDULER_INTERVALS_MS.ACTOR_FOLLOW_SCORES = 1000
|
||||
SCHEDULER_INTERVALS_MS.REMOVE_OLD_JOBS = 10000
|
||||
SCHEDULER_INTERVALS_MS.REMOVE_OLD_HISTORY = 5000
|
||||
SCHEDULER_INTERVALS_MS.REMOVE_OLD_VIEWS = 5000
|
||||
SCHEDULER_INTERVALS_MS.UPDATE_VIDEOS = 5000
|
||||
SCHEDULER_INTERVALS_MS.AUTO_FOLLOW_INDEX_INSTANCES = 5000
|
||||
SCHEDULER_INTERVALS_MS.UPDATE_INBOX_STATS = 5000
|
||||
SCHEDULER_INTERVALS_MS.CHECK_PEERTUBE_VERSION = 2000
|
||||
|
||||
CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max = 100 * 1024 // 100KB
|
||||
CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max = 400 * 1024 // 400KB
|
||||
REPEAT_JOBS['videos-views-stats'] = { every: 5000 }
|
||||
|
||||
SCHEDULER_INTERVALS_MS.ACTOR_FOLLOW_SCORES = 1000
|
||||
SCHEDULER_INTERVALS_MS.REMOVE_OLD_JOBS = 10000
|
||||
SCHEDULER_INTERVALS_MS.REMOVE_OLD_HISTORY = 5000
|
||||
SCHEDULER_INTERVALS_MS.REMOVE_OLD_VIEWS = 5000
|
||||
SCHEDULER_INTERVALS_MS.UPDATE_VIDEOS = 5000
|
||||
SCHEDULER_INTERVALS_MS.AUTO_FOLLOW_INDEX_INSTANCES = 5000
|
||||
SCHEDULER_INTERVALS_MS.UPDATE_INBOX_STATS = 5000
|
||||
SCHEDULER_INTERVALS_MS.CHECK_PEERTUBE_VERSION = 2000
|
||||
REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 }
|
||||
AP_CLEANER.PERIOD = 5000
|
||||
|
||||
REPEAT_JOBS['videos-views-stats'] = { every: 5000 }
|
||||
REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
|
||||
|
||||
REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 }
|
||||
AP_CLEANER.PERIOD = 5000
|
||||
CONTACT_FORM_LIFETIME = 1000 // 1 second
|
||||
|
||||
REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
|
||||
JOB_ATTEMPTS['email'] = 1
|
||||
|
||||
VIEW_LIFETIME.VIEWER_COUNTER = 1000 * 5 // 5 second
|
||||
VIEW_LIFETIME.VIEWER_STATS = 1000 * 5 // 5 second
|
||||
CONTACT_FORM_LIFETIME = 1000 // 1 second
|
||||
FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000
|
||||
MEMOIZE_TTL.OVERVIEWS_SAMPLE = 3000
|
||||
MEMOIZE_TTL.LIVE_ABLE_TO_UPLOAD = 3000
|
||||
OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD = 2
|
||||
|
||||
JOB_ATTEMPTS['email'] = 1
|
||||
PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 5000
|
||||
}
|
||||
|
||||
FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000
|
||||
MEMOIZE_TTL.OVERVIEWS_SAMPLE = 3000
|
||||
MEMOIZE_TTL.LIVE_ABLE_TO_UPLOAD = 3000
|
||||
OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD = 2
|
||||
if (isTestInstance()) {
|
||||
ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2
|
||||
ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
|
||||
ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
|
||||
ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
|
||||
|
||||
PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 5000
|
||||
CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max = 100 * 1024 // 100KB
|
||||
CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max = 400 * 1024 // 400KB
|
||||
|
||||
VIDEO_LIVE.CLEANUP_DELAY = getIntEnv('PEERTUBE_TEST_CONSTANTS_VIDEO_LIVE_CLEANUP_DELAY') ?? 5000
|
||||
VIDEO_LIVE.SEGMENT_TIME_SECONDS.DEFAULT_LATENCY = 2
|
||||
VIDEO_LIVE.SEGMENT_TIME_SECONDS.SMALL_LATENCY = 1
|
||||
VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION = 1
|
||||
VIEW_LIFETIME.VIEWER_COUNTER = 1000 * 5 // 5 second
|
||||
VIEW_LIFETIME.VIEWER_STATS = 1000 * 5 // 5 second
|
||||
|
||||
VIDEO_LIVE.CLEANUP_DELAY = getIntEnv('PEERTUBE_TEST_CONSTANTS_VIDEO_LIVE_CLEANUP_DELAY') ?? 5000
|
||||
VIDEO_LIVE.SEGMENT_TIME_SECONDS.DEFAULT_LATENCY = 2
|
||||
VIDEO_LIVE.SEGMENT_TIME_SECONDS.SMALL_LATENCY = 1
|
||||
VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION = 1
|
||||
}
|
||||
}
|
||||
|
||||
updateWebserverUrls()
|
||||
|
|
|
@ -8,9 +8,10 @@ import { UserNotificationModel } from '@server/models/user/user-notification'
|
|||
import { UserVideoHistoryModel } from '@server/models/user/user-video-history'
|
||||
import { VideoJobInfoModel } from '@server/models/video/video-job-info'
|
||||
import { VideoLiveSessionModel } from '@server/models/video/video-live-session'
|
||||
import { VideoSourceModel } from '@server/models/video/video-source'
|
||||
import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer'
|
||||
import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section'
|
||||
import { isTestInstance } from '../helpers/core-utils'
|
||||
import { isTestOrDevInstance } from '../helpers/core-utils'
|
||||
import { logger } from '../helpers/logger'
|
||||
import { AbuseModel } from '../models/abuse/abuse'
|
||||
import { AbuseMessageModel } from '../models/abuse/abuse-message'
|
||||
|
@ -49,7 +50,6 @@ import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-pla
|
|||
import { VideoTagModel } from '../models/video/video-tag'
|
||||
import { VideoViewModel } from '../models/view/video-view'
|
||||
import { CONFIG } from './config'
|
||||
import { VideoSourceModel } from '@server/models/video/video-source'
|
||||
|
||||
require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string
|
||||
|
||||
|
@ -81,13 +81,13 @@ const sequelizeTypescript = new SequelizeTypescript({
|
|||
pool: {
|
||||
max: poolMax
|
||||
},
|
||||
benchmark: isTestInstance(),
|
||||
benchmark: isTestOrDevInstance(),
|
||||
isolationLevel: Transaction.ISOLATION_LEVELS.SERIALIZABLE,
|
||||
logging: (message: string, benchmark: number) => {
|
||||
if (process.env.NODE_DB_LOG === 'false') return
|
||||
|
||||
let newMessage = 'Executed SQL request'
|
||||
if (isTestInstance() === true && benchmark !== undefined) {
|
||||
if (isTestOrDevInstance() === true && benchmark !== undefined) {
|
||||
newMessage += ' in ' + benchmark + 'ms'
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import express from 'express'
|
|||
import { readFile } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import validator from 'validator'
|
||||
import { isTestOrDevInstance } from '@server/helpers/core-utils'
|
||||
import { toCompleteUUID } from '@server/helpers/custom-validators/misc'
|
||||
import { mdToOneLinePlainText } from '@server/helpers/markdown'
|
||||
import { ActorImageModel } from '@server/models/actor/actor-image'
|
||||
|
@ -30,7 +31,6 @@ import { MAccountActor, MChannelActor } from '../types/models'
|
|||
import { getActivityStreamDuration } from './activitypub/activity'
|
||||
import { getBiggestActorImage } from './actor-image'
|
||||
import { ServerConfigManager } from './server-config-manager'
|
||||
import { isTestInstance } from '@server/helpers/core-utils'
|
||||
|
||||
type Tags = {
|
||||
ogType: string
|
||||
|
@ -234,7 +234,7 @@ class ClientHtml {
|
|||
const path = ClientHtml.getEmbedPath()
|
||||
|
||||
// Disable HTML cache in dev mode because webpack can regenerate JS files
|
||||
if (!isTestInstance() && ClientHtml.htmlCache[path]) {
|
||||
if (!isTestOrDevInstance() && ClientHtml.htmlCache[path]) {
|
||||
return ClientHtml.htmlCache[path]
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ import { readFileSync } from 'fs-extra'
|
|||
import { isArray, merge } from 'lodash'
|
||||
import { createTransport, Transporter } from 'nodemailer'
|
||||
import { join } from 'path'
|
||||
import { root } from '@shared/core-utils'
|
||||
import { EmailPayload } from '@shared/models'
|
||||
import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model'
|
||||
import { isTestInstance } from '../helpers/core-utils'
|
||||
import { root } from '@shared/core-utils'
|
||||
import { isTestOrDevInstance } from '../helpers/core-utils'
|
||||
import { bunyanLogger, logger } from '../helpers/logger'
|
||||
import { CONFIG, isEmailEnabled } from '../initializers/config'
|
||||
import { WEBSERVER } from '../initializers/constants'
|
||||
|
@ -29,7 +29,7 @@ class Emailer {
|
|||
this.initialized = true
|
||||
|
||||
if (!isEmailEnabled()) {
|
||||
if (!isTestInstance()) {
|
||||
if (!isTestOrDevInstance()) {
|
||||
logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!')
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { VideoViewModel } from '@server/models/view/video-view'
|
||||
import { isTestInstance } from '../../../helpers/core-utils'
|
||||
import { isTestOrDevInstance } from '../../../helpers/core-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { VideoModel } from '../../../models/video/video'
|
||||
import { Redis } from '../../redis'
|
||||
|
@ -8,7 +8,7 @@ async function processVideosViewsStats () {
|
|||
const lastHour = new Date()
|
||||
|
||||
// In test mode, we run this function multiple times per hour, so we don't want the values of the previous hour
|
||||
if (!isTestInstance()) lastHour.setHours(lastHour.getHours() - 1)
|
||||
if (!isTestOrDevInstance()) lastHour.setHours(lastHour.getHours() - 1)
|
||||
|
||||
const hour = lastHour.getHours()
|
||||
const startDate = lastHour.setMinutes(0, 0, 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { isTestInstance } from '../../helpers/core-utils'
|
||||
import { isTestOrDevInstance } from '../../helpers/core-utils'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { ACTOR_FOLLOW_SCORE, SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
|
||||
import { ActorFollowModel } from '../../models/actor/actor-follow'
|
||||
|
@ -39,7 +39,7 @@ export class ActorFollowScheduler extends AbstractScheduler {
|
|||
}
|
||||
|
||||
private async removeBadActorFollows () {
|
||||
if (!isTestInstance()) logger.info('Removing bad actor follows (scheduler).')
|
||||
if (!isTestOrDevInstance()) logger.info('Removing bad actor follows (scheduler).')
|
||||
|
||||
try {
|
||||
await ActorFollowModel.removeBadActorFollows()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { isTestInstance } from '../../helpers/core-utils'
|
||||
import { isTestOrDevInstance } from '../../helpers/core-utils'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
|
||||
import { JobQueue } from '../job-queue'
|
||||
import { AbstractScheduler } from './abstract-scheduler'
|
||||
import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
|
||||
|
||||
export class RemoveOldJobsScheduler extends AbstractScheduler {
|
||||
|
||||
|
@ -15,7 +15,7 @@ export class RemoveOldJobsScheduler extends AbstractScheduler {
|
|||
}
|
||||
|
||||
protected internalExecute () {
|
||||
if (!isTestInstance()) logger.info('Removing old jobs in scheduler.')
|
||||
if (!isTestOrDevInstance()) logger.info('Removing old jobs in scheduler.')
|
||||
|
||||
return JobQueue.Instance.removeOldJobs()
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { isTestInstance } from '@server/helpers/core-utils'
|
||||
import { isTestOrDevInstance } from '@server/helpers/core-utils'
|
||||
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
||||
import { VIEW_LIFETIME } from '@server/initializers/constants'
|
||||
import { sendView } from '@server/lib/activitypub/send/send-view'
|
||||
|
@ -117,7 +117,7 @@ export class VideoViewerCounters {
|
|||
if (this.processingViewerCounters) return
|
||||
this.processingViewerCounters = true
|
||||
|
||||
if (!isTestInstance()) logger.info('Cleaning video viewers.', lTags())
|
||||
if (!isTestOrDevInstance()) logger.info('Cleaning video viewers.', lTags())
|
||||
|
||||
try {
|
||||
for (const videoId of this.viewersPerVideo.keys()) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Transaction } from 'sequelize/types'
|
||||
import { isTestInstance } from '@server/helpers/core-utils'
|
||||
import { isTestOrDevInstance } from '@server/helpers/core-utils'
|
||||
import { GeoIP } from '@server/helpers/geo-ip'
|
||||
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
||||
import { MAX_LOCAL_VIEWER_WATCH_SECTIONS, VIEW_LIFETIME } from '@server/initializers/constants'
|
||||
|
@ -118,7 +118,7 @@ export class VideoViewerStats {
|
|||
if (this.processingViewersStats) return
|
||||
this.processingViewersStats = true
|
||||
|
||||
if (!isTestInstance()) logger.info('Processing viewer statistics.', lTags())
|
||||
if (!isTestOrDevInstance()) logger.info('Processing viewer statistics.', lTags())
|
||||
|
||||
const now = new Date().getTime()
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import express from 'express'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { isProdInstance } from '@server/helpers/core-utils'
|
||||
import { isEachUniqueHandleValid, isFollowStateValid, isRemoteHandleValid } from '@server/helpers/custom-validators/follows'
|
||||
import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors'
|
||||
import { getRemoteNameAndHost } from '@server/lib/activitypub/follow'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { MActorFollowActorsDefault } from '@server/types/models'
|
||||
import { ServerFollowCreate } from '@shared/models'
|
||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { isTestInstance } from '../../helpers/core-utils'
|
||||
import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
|
||||
import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
|
||||
import { logger } from '../../helpers/logger'
|
||||
|
@ -14,7 +15,6 @@ import { WEBSERVER } from '../../initializers/constants'
|
|||
import { ActorModel } from '../../models/actor/actor'
|
||||
import { ActorFollowModel } from '../../models/actor/actor-follow'
|
||||
import { areValidationErrors } from './shared'
|
||||
import { ServerFollowCreate } from '@shared/models'
|
||||
|
||||
const listFollowsValidator = [
|
||||
query('state')
|
||||
|
@ -42,7 +42,7 @@ const followValidator = [
|
|||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
// Force https if the administrator wants to follow remote actors
|
||||
if (isTestInstance() === false && WEBSERVER.SCHEME === 'http') {
|
||||
if (isProdInstance() && WEBSERVER.SCHEME === 'http') {
|
||||
return res
|
||||
.status(HttpStatusCode.INTERNAL_SERVER_ERROR_500)
|
||||
.json({
|
||||
|
|
|
@ -5,7 +5,7 @@ import { loadVideo } from '@server/lib/model-loaders'
|
|||
import { VideoPlaylistModel } from '@server/models/video/video-playlist'
|
||||
import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
|
||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { isTestInstance } from '../../helpers/core-utils'
|
||||
import { isTestOrDevInstance } from '../../helpers/core-utils'
|
||||
import { isIdOrUUIDValid, isUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { WEBSERVER } from '../../initializers/constants'
|
||||
|
@ -34,7 +34,7 @@ const isURLOptions = {
|
|||
}
|
||||
|
||||
// We validate 'localhost', so we don't have the top level domain
|
||||
if (isTestInstance()) {
|
||||
if (isTestOrDevInstance()) {
|
||||
isURLOptions.require_tld = false
|
||||
}
|
||||
|
||||
|
|
|
@ -1036,7 +1036,7 @@ $ npm run setup:cli
|
|||
* Run PeerTube (you can access to your instance on http://localhost:9000):
|
||||
|
||||
```
|
||||
$ NODE_ENV=test npm start
|
||||
$ NODE_ENV=dev npm start
|
||||
```
|
||||
|
||||
* Register the instance via the CLI:
|
||||
|
|
Loading…
Reference in New Issue