import { IConfig } from 'config'
import { dirname, join } from 'path'
-import { JobType, VideoRateType, VideoState } from '../../shared/models'
+import { JobType, VideoRateType, VideoState, VideosRedundancy } from '../../shared/models'
import { ActivityPubActorType } from '../../shared/models/activitypub'
import { FollowState } from '../../shared/models/actors'
import { VideoAbuseState, VideoImportState, 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 { buildPath, isTestInstance, parseDuration, root, 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'
// Use a variable to reload the configuration if we need
let config: IConfig = require('config')
// ---------------------------------------------------------------------------
-const LAST_MIGRATION_VERSION = 265
+const LAST_MIGRATION_VERSION = 275
// ---------------------------------------------------------------------------
JOBS: [ 'createdAt' ],
VIDEO_ABUSES: [ 'id', 'createdAt', 'state' ],
VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ],
- VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes' ],
VIDEO_IMPORTS: [ 'createdAt' ],
VIDEO_COMMENT_THREADS: [ 'createdAt' ],
BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ],
FOLLOWERS: [ 'createdAt' ],
FOLLOWING: [ 'createdAt' ],
- VIDEOS_SEARCH: [ 'match', 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes' ],
+ VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ],
+
+ VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'match' ],
VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ]
}
const ROUTE_CACHE_LIFETIME = {
FEEDS: '15 minutes',
ROBOTS: '2 hours',
+ SECURITYTXT: '2 hours',
NODEINFO: '10 minutes',
DNT_POLICY: '1 week',
+ OVERVIEWS: {
+ VIDEOS: '1 hour'
+ },
ACTIVITY_PUB: {
VIDEOS: '1 second' // 1 second, cache concurrent requests after a broadcast for example
- }
+ },
+ STATS: '4 hours'
}
// ---------------------------------------------------------------------------
'activitypub-follow': 60000 * 10, // 10 minutes
'video-file-import': 1000 * 3600, // 1 hour
'video-file': 1000 * 3600 * 48, // 2 days, transcoding could be long
- 'video-import': 1000 * 3600 * 5, // 5 hours
+ 'video-import': 1000 * 3600 * 2, // hours
'email': 60000 * 10, // 10 minutes
'videos-views': undefined // Unlimited
}
const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...)
const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds
const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days
+const VIDEO_IMPORT_TIMEOUT = 1000 * 3600 // 1 hour
// 1 hour
let SCHEDULER_INTERVALS_MS = {
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'))
+ }
+ },
ADMIN: {
get EMAIL () { return config.get<string>('admin.email') }
},
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 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: {
}
}
},
+ VIDEOS_REDUNDANCY: {
+ URL: { min: 3, max: 2000 } // Length
+ },
VIDEOS: {
NAME: { min: 3, max: 120 }, // Length
LANGUAGE: { min: 1, max: 10 }, // Length
LOGIN: {
WINDOW_MS: 5 * 60 * 1000, // 5 minutes
MAX: 15 // 15 attempts
+ },
+ ASK_SEND_EMAIL: {
+ WINDOW_MS: 5 * 60 * 1000, // 5 minutes
+ MAX: 3 // 3 attempts
}
}
// ---------------------------------------------------------------------------
+const OVERVIEWS = {
+ VIDEOS: {
+ SAMPLE_THRESHOLD: 6,
+ SAMPLES_COUNT: 2
+ }
+}
+
+// ---------------------------------------------------------------------------
+
const SERVER_ACTOR_NAME = 'peertube'
const ACTIVITY_PUB = {
}
}
+const MEMOIZE_TTL = {
+ OVERVIEWS_SAMPLE: 1000 * 3600 * 4 // 4 hours
+}
+
+const REDUNDANCY = {
+ VIDEOS: {
+ RANDOMIZED_FACTOR: 5
+ }
+}
+
const ACCEPT_HEADERS = [ 'html', 'application/json' ].concat(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS)
// ---------------------------------------------------------------------------
SCHEDULER_INTERVALS_MS.updateVideos = 5000
REPEAT_JOBS['videos-views'] = { every: 5000 }
+ REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1
+
VIDEO_VIEW_LIFETIME = 1000 // 1 second
JOB_ATTEMPTS['email'] = 1
CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000
+ MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1
+ ROUTE_CACHE_LIFETIME.OVERVIEWS.VIDEOS = '0ms'
}
updateWebserverConfig()
CONFIG,
CONSTRAINTS_FIELDS,
EMBED_SIZE,
+ REDUNDANCY,
JOB_CONCURRENCY,
JOB_ATTEMPTS,
LAST_MIGRATION_VERSION,
TORRENT_MIMETYPE_EXT,
STATIC_MAX_AGE,
STATIC_PATHS,
+ VIDEO_IMPORT_TIMEOUT,
ACTIVITY_PUB,
ACTIVITY_PUB_ACTOR_TYPES,
THUMBNAILS_SIZE,
VIDEO_ABUSE_STATES,
JOB_REQUEST_TIMEOUT,
USER_PASSWORD_RESET_LIFETIME,
+ MEMOIZE_TTL,
USER_EMAIL_VERIFY_LIFETIME,
IMAGE_MIMETYPE_EXT,
+ OVERVIEWS,
SCHEDULER_INTERVALS_MS,
REPEAT_JOBS,
STATIC_DOWNLOAD_PATHS,
CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP)
}
+function buildVideosRedundancy (objs: any[]): VideosRedundancy[] {
+ if (!objs) return []
+
+ 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')
})
.forEach(l => languages[l.iso6391 || l.iso6393] = l.name)
+ // Override Occitan label
+ languages['oc'] = 'Occitan'
+
return languages
}