X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fconstants.ts;h=2e9d3956ea52e88c4cefe2ce8806d004bb397eb6;hb=4f32032fed8587ea97d45e235b167e8958efd81f;hp=e5cac64d4961e33e875a3037cb86b40bd0a4440d;hpb=2ca154da93acb7b87a12f6a9477d90cfb2a10475;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index e5cac64d4..2e9d3956e 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -1,8 +1,17 @@ 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' @@ -14,7 +23,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 505 +const LAST_MIGRATION_VERSION = 520 // --------------------------------------------------------------------------- @@ -50,7 +59,6 @@ const SORTABLE_COLUMNS = { 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' ], @@ -61,9 +69,12 @@ const SORTABLE_COLUMNS = { VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'trending' ], + // 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' ], @@ -191,7 +202,7 @@ 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 }, @@ -372,13 +383,14 @@ const VIDEO_STATES = { 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 = { @@ -631,7 +643,8 @@ const AUDIT_LOG_FILENAME = 'peertube-audit.log' 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 @@ -648,6 +661,15 @@ 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 @@ -698,11 +720,20 @@ registerConfigChangedHandler(() => { // --------------------------------------------------------------------------- +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, @@ -756,7 +787,7 @@ export { VIDEO_RATE_TYPES, VIDEO_TRANSCODING_FPS, FFMPEG_NICE, - VIDEO_ABUSE_STATES, + ABUSE_STATES, VIDEO_CHANNELS, LRU_CACHE, JOB_REQUEST_TIMEOUT, @@ -779,8 +810,10 @@ export { VIDEO_PLAYLIST_PRIVACIES, PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME, ASSETS_PATH, + FILES_CONTENT_HASH, loadLanguages, - buildLanguages + buildLanguages, + generateContentHash } // --------------------------------------------------------------------------- @@ -882,3 +915,7 @@ function buildLanguages () { return languages } + +function generateContentHash () { + return randomBytes(20).toString('hex') +}