import { join } from 'path'
-import { JobType, VideoRateType, VideoResolution, VideoState } from '../../shared/models'
+import { randomBytes } from 'crypto'
import { ActivityPubActorType } from '../../shared/models/activitypub'
import { FollowState } from '../../shared/models/actors'
-import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos'
+import {
+ AbuseState,
+ VideoImportState,
+ VideoPrivacy,
+ VideoTranscodingFPS,
+ JobType,
+ VideoRateType,
+ VideoResolution,
+ VideoState
+} from '../../shared/models'
// Do not use barrels, remain constants as independent as possible
import { isTestInstance, sanitizeHost, sanitizeUrl, root } from '../helpers/core-utils'
import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
// ---------------------------------------------------------------------------
-const LAST_MIGRATION_VERSION = 480
+const LAST_MIGRATION_VERSION = 525
// ---------------------------------------------------------------------------
// Sortable columns per schema
const SORTABLE_COLUMNS = {
- USERS: [ 'id', 'username', 'videoQuotaUsed', 'createdAt' ],
+ USERS: [ 'id', 'username', 'videoQuotaUsed', 'createdAt', 'lastLoginDate', 'role' ],
USER_SUBSCRIPTIONS: [ 'id', 'createdAt' ],
ACCOUNTS: [ 'createdAt' ],
JOBS: [ 'createdAt' ],
- VIDEO_ABUSES: [ 'id', 'createdAt', 'state' ],
VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ],
VIDEO_IMPORTS: [ 'createdAt' ],
VIDEO_COMMENT_THREADS: [ 'createdAt', 'totalReplies' ],
FOLLOWERS: [ 'createdAt', 'state', 'score' ],
FOLLOWING: [ 'createdAt', 'redundancyAllowed', 'state' ],
- VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ],
+ VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'trending' ],
- VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'match' ],
+ // Don't forget to update peertube-search-index with the same values
+ VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'match' ],
VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ],
+ ABUSES: [ 'id', 'createdAt', 'state' ],
+
ACCOUNTS_BLOCKLIST: [ 'createdAt' ],
SERVERS_BLOCKLIST: [ 'createdAt' ],
- USER_NOTIFICATIONS: [ 'createdAt' ],
+ USER_NOTIFICATIONS: [ 'createdAt', 'read' ],
VIDEO_PLAYLISTS: [ 'displayName', 'createdAt', 'updatedAt' ],
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
},
const JOB_TTL: { [id in JobType]: number } = {
'activitypub-http-broadcast': 60000 * 10, // 10 minutes
'activitypub-http-unicast': 60000 * 10, // 10 minutes
- 'activitypub-http-fetcher': 60000 * 10, // 10 minutes
+ 'activitypub-http-fetcher': 1000 * 3600 * 10, // 10 hours
'activitypub-follow': 60000 * 10, // 10 minutes
'video-file-import': 1000 * 3600, // 1 hour
'video-transcoding': 1000 * 3600 * 48, // 2 days, transcoding could be long
- 'video-import': 1000 * 3600 * 2, // hours
+ 'video-import': 1000 * 3600 * 2, // 2 hours
'email': 60000 * 10, // 10 minutes
'videos-views': undefined, // Unlimited
'activitypub-refresher': 60000 * 10, // 10 minutes
removeOldHistory: 60000 * 60 * 24 // 1 day
}
-const INSTANCES_INDEX = {
- HOSTS_PATH: '/api/v1/instances/hosts'
-}
-
// ---------------------------------------------------------------------------
const CONSTRAINTS_FIELDS = {
VIDEO_LANGUAGES: { max: 500 }, // Array length
BLOCKED_REASON: { min: 3, max: 250 } // Length
},
- VIDEO_ABUSES: {
+ ABUSES: {
REASON: { min: 2, max: 3000 }, // Length
MODERATION_COMMENT: { min: 2, max: 3000 } // Length
},
+ ABUSE_MESSAGES: {
+ MESSAGE: { min: 2, max: 3000 } // Length
+ },
VIDEO_BLACKLIST: {
REASON: { min: 2, max: 300 } // Length
},
COUNT: { min: 0 }
},
VIDEO_COMMENTS: {
- TEXT: { min: 1, max: 3000 }, // Length
+ TEXT: { min: 1, max: 10000 }, // Length
URL: { min: 3, max: 2000 } // Length
},
VIDEO_SHARE: {
const VIDEO_IMPORT_STATES = {
[VideoImportState.FAILED]: 'Failed',
[VideoImportState.PENDING]: 'Pending',
- [VideoImportState.SUCCESS]: 'Success'
+ [VideoImportState.SUCCESS]: 'Success',
+ [VideoImportState.REJECTED]: 'Rejected'
}
-const VIDEO_ABUSE_STATES = {
- [VideoAbuseState.PENDING]: 'Pending',
- [VideoAbuseState.REJECTED]: 'Rejected',
- [VideoAbuseState.ACCEPTED]: 'Accepted'
+const ABUSE_STATES = {
+ [AbuseState.PENDING]: 'Pending',
+ [AbuseState.REJECTED]: 'Rejected',
+ [AbuseState.ACCEPTED]: 'Accepted'
}
const VIDEO_PLAYLIST_PRIVACIES = {
const OVERVIEWS = {
VIDEOS: {
SAMPLE_THRESHOLD: 6,
- SAMPLES_COUNT: 2
+ SAMPLES_COUNT: 20
}
}
ACCEPT_HEADER: 'application/activity+json, application/ld+json',
PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
COLLECTION_ITEMS_PER_PAGE: 10,
- FETCH_PAGE_LIMIT: 100,
+ FETCH_PAGE_LIMIT: 2000,
URL_MIME_TYPES: {
VIDEO: [] as string[],
TORRENT: [ 'application/x-bittorrent' ],
const BCRYPT_SALT_SIZE = 10
const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes
+const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days
const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes
const TRACKER_RATE_LIMITS = {
INTERVAL: 60000 * 5, // 5 minutes
ANNOUNCES_PER_IP_PER_INFOHASH: 15, // maximum announces per torrent in the interval
- ANNOUNCES_PER_IP: 30 // maximum announces for all our torrents in the interval
+ ANNOUNCES_PER_IP: 30, // maximum announces for all our torrents in the interval
+ BLOCK_IP_LIFETIME: 60000 * 10 // 10 minutes
}
const P2P_MEDIA_LOADER_PEER_VERSION = 2
const PLUGIN_GLOBAL_CSS_FILE_NAME = 'plugins-global.css'
const PLUGIN_GLOBAL_CSS_PATH = join(CONFIG.STORAGE.TMP_DIR, PLUGIN_GLOBAL_CSS_FILE_NAME)
+let PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 1000 * 60 * 5 // 5 minutes
+
const DEFAULT_THEME_NAME = 'default'
const DEFAULT_USER_THEME_NAME = 'instance-default'
// ---------------------------------------------------------------------------
+const SEARCH_INDEX = {
+ ROUTES: {
+ VIDEOS: '/api/v1/search/videos',
+ VIDEO_CHANNELS: '/api/v1/search/video-channels'
+ }
+}
+
+// ---------------------------------------------------------------------------
+
// Special constants for a test instance
if (isTestInstance() === true) {
PRIVATE_RSA_KEY_SIZE = 1024
JOB_ATTEMPTS['email'] = 1
FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000
- MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1
- ROUTE_CACHE_LIFETIME.OVERVIEWS.VIDEOS = '0ms'
+ MEMOIZE_TTL.OVERVIEWS_SAMPLE = 3000
+ OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD = 2
+
+ PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 5000
}
updateWebserverUrls()
// ---------------------------------------------------------------------------
+const FILES_CONTENT_HASH = {
+ MANIFEST: generateContentHash(),
+ FAVICON: generateContentHash(),
+ LOGO: generateContentHash()
+}
+
+// ---------------------------------------------------------------------------
+
export {
WEBSERVER,
API_VERSION,
PEERTUBE_VERSION,
LAZY_STATIC_PATHS,
+ SEARCH_INDEX,
HLS_REDUNDANCY_DIRECTORY,
P2P_MEDIA_LOADER_PEER_VERSION,
AVATARS_SIZE,
PREVIEWS_SIZE,
REMOTE_SCHEME,
FOLLOW_STATES,
- INSTANCES_INDEX,
DEFAULT_USER_THEME_NAME,
SERVER_ACTOR_NAME,
PLUGIN_GLOBAL_CSS_FILE_NAME,
VIDEO_RATE_TYPES,
VIDEO_TRANSCODING_FPS,
FFMPEG_NICE,
- VIDEO_ABUSE_STATES,
+ ABUSE_STATES,
VIDEO_CHANNELS,
LRU_CACHE,
JOB_REQUEST_TIMEOUT,
USER_PASSWORD_RESET_LIFETIME,
+ USER_PASSWORD_CREATE_LIFETIME,
MEMOIZE_TTL,
USER_EMAIL_VERIFY_LIFETIME,
OVERVIEWS,
VIDEO_VIEW_LIFETIME,
CONTACT_FORM_LIFETIME,
VIDEO_PLAYLIST_PRIVACIES,
+ PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME,
ASSETS_PATH,
+ FILES_CONTENT_HASH,
loadLanguages,
- buildLanguages
+ buildLanguages,
+ generateContentHash
}
// ---------------------------------------------------------------------------
return languages
}
+
+function generateContentHash () {
+ return randomBytes(20).toString('hex')
+}