]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/constants.ts
Continue activitypub
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.ts
index 54dce980f8e8ce52d553df5b978ef18290202d0e..e1f877e80ca146c6fe8701659623f0fd2dbd8d63 100644 (file)
@@ -5,18 +5,19 @@ import { join } from 'path'
 import { root, isTestInstance } from '../helpers/core-utils'
 
 import {
-  UserRole,
   VideoRateType,
   RequestEndpoint,
   RequestVideoEventType,
   RequestVideoQaduType,
   RemoteVideoRequestType,
-  JobState
+  JobState,
+  JobCategory
 } from '../../shared/models'
+import { VideoPrivacy } from '../../shared/models/videos/video-privacy.enum'
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 75
+const LAST_MIGRATION_VERSION = 95
 
 // ---------------------------------------------------------------------------
 
@@ -60,7 +61,6 @@ const CONFIG = {
     PASSWORD: config.get<string>('database.password')
   },
   STORAGE: {
-    CERT_DIR: join(root(), config.get<string>('storage.certs')),
     LOG_DIR: join(root(), config.get<string>('storage.logs')),
     VIDEOS_DIR: join(root(), config.get<string>('storage.videos')),
     THUMBNAILS_DIR: join(root(), config.get<string>('storage.thumbnails')),
@@ -118,17 +118,18 @@ const CONSTRAINTS_FIELDS = {
     REASON: { min: 2, max: 300 } // Length
   },
   VIDEO_CHANNELS: {
-    NAME: { min: 3, max: 50 }, // Length
+    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 },
@@ -196,6 +197,18 @@ const VIDEO_LANGUAGES = {
   14: 'Italian'
 }
 
+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'
+}
+
 // ---------------------------------------------------------------------------
 
 // Score a pod has when we create it as a friend
@@ -204,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
@@ -234,42 +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 ]: {
-    [ id: string ]: RemoteVideoRequestType
-  }
-} = {}
-REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = {
-  ADD_VIDEO: 'add-video',
-  UPDATE_VIDEO: 'update-video',
-  REMOVE_VIDEO: 'remove-video',
-  ADD_CHANNEL: 'add-channel',
-  UPDATE_CHANNEL: 'update-channel',
-  REMOVE_CHANNEL: 'remove-channel',
-  ADD_AUTHOR: 'add-author',
-  REMOVE_AUTHOR: 'remove-author',
-  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'
@@ -281,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
@@ -334,13 +325,6 @@ const CACHE = {
 
 // ---------------------------------------------------------------------------
 
-const USER_ROLES: { [ id: string ]: UserRole } = {
-  ADMIN: 'admin',
-  USER: 'user'
-}
-
-// ---------------------------------------------------------------------------
-
 const OPENGRAPH_AND_OEMBED_COMMENT = '<!-- open graph and oembed tags -->'
 
 // ---------------------------------------------------------------------------
@@ -367,17 +351,15 @@ export {
   EMBED_SIZE,
   FRIEND_SCORE,
   JOB_STATES,
-  JOBS_CONCURRENCY,
   JOBS_FETCH_LIMIT_PER_CYCLE,
   JOBS_FETCHING_INTERVAL,
+  JOB_CATEGORIES,
   LAST_MIGRATION_VERSION,
   OAUTH_LIFETIME,
   OPENGRAPH_AND_OEMBED_COMMENT,
   PAGINATION_COUNT_DEFAULT,
   PODS_SCORE,
   PREVIEWS_SIZE,
-  PRIVATE_CERT_NAME,
-  PUBLIC_CERT_NAME,
   REMOTE_SCHEME,
   REQUEST_ENDPOINT_ACTIONS,
   REQUEST_ENDPOINTS,
@@ -395,15 +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_LANGUAGES,
+  VIDEO_PRIVACIES,
   VIDEO_LICENCES,
-  VIDEO_RATE_TYPES
+  VIDEO_RATE_TYPES,
+  VIDEO_MIMETYPE_EXT
 }