X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fconstants.ts;h=e1f877e80ca146c6fe8701659623f0fd2dbd8d63;hb=0d0e8dd0904b380b70e19ebcb4763d65601c4632;hp=f87041a3ffe127e9ffbfda527f4fe9b2669a4e21;hpb=ecb455b6c42bd75c9d87294c2479fa53b739d0a8;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index f87041a3f..e1f877e80 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -5,17 +5,19 @@ import { join } from 'path' import { root, isTestInstance } from '../helpers/core-utils' import { - UserRole, VideoRateType, RequestEndpoint, RequestVideoEventType, RequestVideoQaduType, - JobState + RemoteVideoRequestType, + JobState, + JobCategory } from '../../shared/models' +import { VideoPrivacy } from '../../shared/models/videos/video-privacy.enum' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 75 +const LAST_MIGRATION_VERSION = 95 // --------------------------------------------------------------------------- @@ -32,8 +34,10 @@ const SEARCHABLE_COLUMNS = { // Sortable columns per schema const SORTABLE_COLUMNS = { + PODS: [ 'id', 'host', 'score', 'createdAt' ], USERS: [ 'id', 'username', 'createdAt' ], VIDEO_ABUSES: [ 'id', 'createdAt' ], + VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ], VIDEOS: [ 'name', 'duration', 'createdAt', 'views', 'likes' ], BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ] } @@ -57,7 +61,6 @@ const CONFIG = { PASSWORD: config.get('database.password') }, STORAGE: { - CERT_DIR: join(root(), config.get('storage.certs')), LOG_DIR: join(root(), config.get('storage.logs')), VIDEOS_DIR: join(root(), config.get('storage.videos')), THUMBNAILS_DIR: join(root(), config.get('storage.thumbnails')), @@ -114,14 +117,19 @@ const CONSTRAINTS_FIELDS = { VIDEO_ABUSES: { REASON: { min: 2, max: 300 } // Length }, + VIDEO_CHANNELS: { + NAME: { min: 3, max: 120 }, // Length + DESCRIPTION: { min: 3, max: 250 } // Length + }, VIDEOS: { - NAME: { min: 3, max: 50 }, // Length - DESCRIPTION: { min: 3, max: 250 }, // Length + NAME: { min: 3, max: 120 }, // Length + TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length + DESCRIPTION: { min: 3, max: 3000 }, // Length EXTNAME: [ '.mp4', '.ogv', '.webm' ], INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2 DURATION: { min: 1, max: 7200 }, // Number - TAGS: { min: 0, max: 3 }, // Number of total tags - TAG: { min: 2, max: 10 }, // Length + TAGS: { min: 0, max: 5 }, // Number of total tags + TAG: { min: 2, max: 30 }, // Length THUMBNAIL: { min: 2, max: 30 }, THUMBNAIL_DATA: { min: 0, max: 20000 }, // Bytes VIEWS: { min: 0 }, @@ -189,14 +197,16 @@ const VIDEO_LANGUAGES = { 14: 'Italian' } -// TODO: use VideoResolution when https://github.com/Microsoft/TypeScript/issues/13042 is fixed -const VIDEO_FILE_RESOLUTIONS: { [ id: number ]: string } = { - 0: 'original', - 240: '240p', - 360: '360p', - 480: '480p', - 720: '720p', - 1080: '1080p' +const VIDEO_PRIVACIES = { + [VideoPrivacy.PUBLIC]: 'Public', + [VideoPrivacy.UNLISTED]: 'Unlisted', + [VideoPrivacy.PRIVATE]: 'Private' +} + +const VIDEO_MIMETYPE_EXT = { + 'video/webm': 'webm', + 'video/ogg': 'ogv', + 'video/mp4': 'mp4' } // --------------------------------------------------------------------------- @@ -207,6 +217,17 @@ const FRIEND_SCORE = { MAX: 1000 } +const ACTIVITY_PUB = { + COLLECTION_ITEMS_PER_PAGE: 10, + VIDEO_URL_MIME_TYPES: [ + 'video/mp4', + 'video/webm', + 'video/ogg', + 'application/x-bittorrent', + 'application/x-bittorrent;x-scheme-handler/magnet' + ] +} + // --------------------------------------------------------------------------- // Number of points we add/remove from a friend after a successful/bad request @@ -237,33 +258,6 @@ const REQUESTS_VIDEO_EVENT_LIMIT_PER_POD = 50 // Number of requests to retry for replay requests module const RETRY_REQUESTS = 5 -const REQUEST_ENDPOINTS: { [ id: string ]: RequestEndpoint } = { - VIDEOS: 'videos' -} - -const REQUEST_ENDPOINT_ACTIONS: { [ id: string ]: any } = {} -REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = { - ADD: 'add', - UPDATE: 'update', - REMOVE: 'remove', - REPORT_ABUSE: 'report-abuse' -} - -const REQUEST_VIDEO_QADU_ENDPOINT = 'videos/qadu' -const REQUEST_VIDEO_EVENT_ENDPOINT = 'videos/events' - -const REQUEST_VIDEO_QADU_TYPES: { [ id: string ]: RequestVideoQaduType } = { - LIKES: 'likes', - DISLIKES: 'dislikes', - VIEWS: 'views' -} - -const REQUEST_VIDEO_EVENT_TYPES: { [ id: string ]: RequestVideoEventType } = { - LIKES: 'likes', - DISLIKES: 'dislikes', - VIEWS: 'views' -} - const REMOTE_SCHEME = { HTTP: 'https', WS: 'wss' @@ -275,18 +269,21 @@ const JOB_STATES: { [ id: string ]: JobState } = { ERROR: 'error', SUCCESS: 'success' } +const JOB_CATEGORIES: { [ id: string ]: JobCategory } = { + TRANSCODING: 'transcoding', + HTTP_REQUEST: 'http-request' +} // How many maximum jobs we fetch from the database per cycle -const JOBS_FETCH_LIMIT_PER_CYCLE = 10 -const JOBS_CONCURRENCY = 1 +const JOBS_FETCH_LIMIT_PER_CYCLE = { + transcoding: 10, + httpRequest: 20 +} // 1 minutes let JOBS_FETCHING_INTERVAL = 60000 // --------------------------------------------------------------------------- -const PRIVATE_CERT_NAME = 'peertube.key.pem' -const PUBLIC_CERT_NAME = 'peertube.pub' -const SIGNATURE_ALGORITHM = 'RSA-SHA256' -const SIGNATURE_ENCODING = 'hex' +const PRIVATE_RSA_KEY_SIZE = 2048 // Password encryption const BCRYPT_SALT_SIZE = 10 @@ -305,8 +302,19 @@ const STATIC_PATHS = { let STATIC_MAX_AGE = '30d' // Videos thumbnail size -const THUMBNAILS_SIZE = '200x110' -const PREVIEWS_SIZE = '640x480' +const THUMBNAILS_SIZE = { + width: 200, + height: 110 +} +const PREVIEWS_SIZE = { + width: 560, + height: 315 +} + +const EMBED_SIZE = { + width: 560, + height: 315 +} // Sub folders of cache directory const CACHE = { @@ -317,14 +325,7 @@ const CACHE = { // --------------------------------------------------------------------------- -const USER_ROLES: { [ id: string ]: UserRole } = { - ADMIN: 'admin', - USER: 'user' -} - -// --------------------------------------------------------------------------- - -const OPENGRAPH_COMMENT = '' +const OPENGRAPH_AND_OEMBED_COMMENT = '' // --------------------------------------------------------------------------- @@ -347,19 +348,18 @@ export { CACHE, CONFIG, CONSTRAINTS_FIELDS, + EMBED_SIZE, FRIEND_SCORE, JOB_STATES, - JOBS_CONCURRENCY, JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCHING_INTERVAL, + JOB_CATEGORIES, LAST_MIGRATION_VERSION, OAUTH_LIFETIME, - OPENGRAPH_COMMENT, + OPENGRAPH_AND_OEMBED_COMMENT, PAGINATION_COUNT_DEFAULT, PODS_SCORE, PREVIEWS_SIZE, - PRIVATE_CERT_NAME, - PUBLIC_CERT_NAME, REMOTE_SCHEME, REQUEST_ENDPOINT_ACTIONS, REQUEST_ENDPOINTS, @@ -377,16 +377,16 @@ export { REQUESTS_VIDEO_QADU_LIMIT_PODS, RETRY_REQUESTS, SEARCHABLE_COLUMNS, - SIGNATURE_ALGORITHM, - SIGNATURE_ENCODING, + PRIVATE_RSA_KEY_SIZE, SORTABLE_COLUMNS, STATIC_MAX_AGE, STATIC_PATHS, + ACTIVITY_PUB, THUMBNAILS_SIZE, - USER_ROLES, VIDEO_CATEGORIES, - VIDEO_FILE_RESOLUTIONS, VIDEO_LANGUAGES, + VIDEO_PRIVACIES, VIDEO_LICENCES, - VIDEO_RATE_TYPES + VIDEO_RATE_TYPES, + VIDEO_MIMETYPE_EXT }