import { VideoPrivacy } from '../../shared/models/videos'
// Do not use barrels, remain constants as independent as possible
import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
+import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
// Use a variable to reload the configuration if we need
let config: IConfig = require('config')
// ---------------------------------------------------------------------------
-const LAST_MIGRATION_VERSION = 195
+const LAST_MIGRATION_VERSION = 215
// ---------------------------------------------------------------------------
JOBS: [ 'createdAt' ],
VIDEO_ABUSES: [ 'id', 'createdAt' ],
VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ],
- VIDEOS: [ 'name', 'duration', 'createdAt', 'views', 'likes' ],
+ VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes' ],
VIDEO_COMMENT_THREADS: [ 'createdAt' ],
BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ],
FOLLOWERS: [ 'createdAt' ],
REFRESH_TOKEN: 1209600 // 2 weeks
}
+const ROUTE_CACHE_LIFETIME = {
+ FEEDS: 1000 * 60 * 15, // 15 minutes
+ ACTIVITY_PUB: {
+ VIDEOS: 1000 // 1 second, cache concurrent requests after a broadcast for example
+ }
+}
+
// ---------------------------------------------------------------------------
// Number of points we add/remove after a successful/bad request
'activitypub-http-broadcast': 5,
'activitypub-http-unicast': 5,
'activitypub-http-fetcher': 5,
+ 'activitypub-follow': 5,
'video-file': 1,
'email': 5
}
'activitypub-http-broadcast': 1,
'activitypub-http-unicast': 5,
'activitypub-http-fetcher': 1,
+ 'activitypub-follow': 3,
'video-file': 1,
'email': 5
}
-// 2 days
-const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2
+const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job
+const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds
+const JOB_REQUEST_TTL = 60000 * 10 // 10 minutes
+const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days
// 1 hour
let SCHEDULER_INTERVAL = 60000 * 60
const CONFIG = {
CUSTOM_FILE: getLocalConfigFilePath(),
LISTEN: {
- PORT: config.get<number>('listen.port')
+ PORT: config.get<number>('listen.port'),
+ HOSTNAME: config.get<string>('listen.hostname')
},
DATABASE: {
DBNAME: 'peertube' + config.get<string>('database.suffix'),
get DESCRIPTION () { return config.get<string>('instance.description') },
get TERMS () { return config.get<string>('instance.terms') },
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') }
+ },
+ SERVICES: {
+ TWITTER: {
+ get USERNAME () { return config.get<string>('services.twitter.username') },
+ get WHITELISTED () { return config.get<boolean>('services.twitter.whitelisted') }
}
}
}
const CONSTRAINTS_FIELDS = {
USERS: {
+ NAME: { min: 3, max: 120 }, // Length
+ DESCRIPTION: { min: 3, max: 250 }, // Length
USERNAME: { min: 3, max: 20 }, // Length
PASSWORD: { min: 6, max: 255 }, // Length
- DESCRIPTION: { min: 3, max: 250 }, // Length
VIDEO_QUOTA: { min: -1 }
},
VIDEO_ABUSES: {
},
VIDEO_CHANNELS: {
NAME: { min: 3, max: 120 }, // Length
- DESCRIPTION: { min: 3, max: 250 }, // Length
- SUPPORT: { min: 3, max: 300 }, // Length
+ DESCRIPTION: { min: 3, max: 500 }, // Length
+ SUPPORT: { min: 3, max: 500 }, // Length
URL: { min: 3, max: 2000 } // Length
},
VIDEOS: {
NAME: { min: 3, max: 120 }, // Length
+ LANGUAGE: { min: 1, max: 10 }, // Length
TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length
DESCRIPTION: { min: 3, max: 10000 }, // Length
- SUPPORT: { min: 3, max: 300 }, // Length
+ SUPPORT: { min: 3, max: 500 }, // Length
IMAGE: {
EXTNAME: [ '.jpg', '.jpeg' ],
FILE_SIZE: {
7: 'Public Domain Dedication'
}
-// See https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers#Nationalencyklopedin
-const VIDEO_LANGUAGES = {
- 1: 'English',
- 2: 'Spanish',
- 3: 'Mandarin',
- 4: 'Hindi',
- 5: 'Arabic',
- 6: 'Portuguese',
- 7: 'Bengali',
- 8: 'Russian',
- 9: 'Japanese',
- 10: 'Punjabi',
- 11: 'German',
- 12: 'Korean',
- 13: 'French',
- 14: 'Italian',
- 1000: 'Sign Language',
- 1001: 'American Sign Language',
- 1002: 'Arab Sign Language',
- 1003: 'British Sign Language',
- 1004: 'Brazilian Sign Language',
- 1005: 'Chinese Sign Language',
- 1006: 'Czech Sign Language',
- 1007: 'Danish Sign Language',
- 1008: 'French Sign Language',
- 1009: 'German Sign Language',
- 1010: 'Indo-Pakistani Sign Language',
- 1011: 'Japanese Sign Language',
- 1012: 'South African Sign Language',
- 1013: 'Swedish Sign Language',
- 1014: 'Russian Sign Language'
-}
+const VIDEO_LANGUAGES = buildLanguages()
const VIDEO_PRIVACIES = {
[VideoPrivacy.PUBLIC]: 'Public',
const USER_PASSWORD_RESET_LIFETIME = 60000 * 5 // 5 minutes
+const NSFW_POLICY_TYPES: { [ id: string]: NSFWPolicyType } = {
+ DO_NOT_LIST: 'do_not_list',
+ BLUR: 'blur',
+ DISPLAY: 'display'
+}
+
// ---------------------------------------------------------------------------
// Express static paths (router)
// ---------------------------------------------------------------------------
+const FEEDS = {
+ COUNT: 20
+}
+
+// ---------------------------------------------------------------------------
+
// Special constants for a test instance
if (isTestInstance() === true) {
ACTOR_FOLLOW_SCORE.BASE = 20
LAST_MIGRATION_VERSION,
OAUTH_LIFETIME,
OPENGRAPH_AND_OEMBED_COMMENT,
+ BROADCAST_CONCURRENCY,
PAGINATION_COUNT_DEFAULT,
ACTOR_FOLLOW_SCORE,
PREVIEWS_SIZE,
FOLLOW_STATES,
SERVER_ACTOR_NAME,
PRIVATE_RSA_KEY_SIZE,
+ ROUTE_CACHE_LIFETIME,
SORTABLE_COLUMNS,
+ FEEDS,
+ NSFW_POLICY_TYPES,
STATIC_MAX_AGE,
STATIC_PATHS,
ACTIVITY_PUB,
VIDEO_RATE_TYPES,
VIDEO_MIMETYPE_EXT,
VIDEO_TRANSCODING_FPS,
+ JOB_REQUEST_TIMEOUT,
+ JOB_REQUEST_TTL,
USER_PASSWORD_RESET_LIFETIME,
IMAGE_MIMETYPE_EXT,
SCHEDULER_INTERVAL,
CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP)
}
+function buildLanguages () {
+ const iso639 = require('iso-639-3')
+
+ const languages: { [ id: string ]: string } = {}
+
+ const signLanguages = [
+ 'sgn', // Sign languages (macro language)
+ 'ase', // American
+ 'sdl', // Arabian
+ 'bfi', // British
+ 'bzs', // Brazilian
+ 'csl', // Chinese
+ 'cse', // Czech
+ 'dsl', // Danish
+ 'fsl', // French
+ 'gsg', // German
+ 'pks', // Pakistan
+ 'jsl', // Japanese
+ 'sfs', // South African
+ 'swl', // Swedish
+ 'rsl' // Russian
+ ]
+
+ // Only add ISO639-1 languages and some sign languages (ISO639-3)
+ iso639
+ .filter(l => {
+ return (l.iso6391 !== null && l.type === 'living') ||
+ signLanguages.indexOf(l.iso6393) !== -1
+ })
+ .forEach(l => languages[l.iso6391 || l.iso6393] = l.name)
+
+ return languages
+}
+
export function reloadConfig () {
function directory () {