]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/constants.js
Format video blacklist
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.js
index ad7cf4f4da9e3efb7d198af0e594899fdd3ae104..d6da20982b29a0eded0e0c70dfebda862db334dd 100644 (file)
@@ -5,6 +5,10 @@ const path = require('path')
 
 // ---------------------------------------------------------------------------
 
+const LAST_MIGRATION_VERSION = 50
+
+// ---------------------------------------------------------------------------
+
 // API version
 const API_VERSION = 'v1'
 
@@ -18,9 +22,9 @@ const SEARCHABLE_COLUMNS = {
 
 // Sortable columns per schema
 const SORTABLE_COLUMNS = {
-  USERS: [ 'id', '-id', 'username', '-username', 'createdAt', '-createdAt' ],
-  VIDEO_ABUSES: [ 'id', '-id', 'createdAt', '-createdAt' ],
-  VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdAt', '-createdAt' ]
+  USERS: [ 'id', 'username', 'createdAt' ],
+  VIDEO_ABUSES: [ 'id', 'createdAt' ],
+  VIDEOS: [ 'name', 'duration', 'createdAt', 'views', 'likes' ]
 }
 
 const OAUTH_LIFETIME = {
@@ -54,6 +58,12 @@ const CONFIG = {
     WS: config.get('webserver.https') === true ? 'wss' : 'ws',
     HOSTNAME: config.get('webserver.hostname'),
     PORT: config.get('webserver.port')
+  },
+  ADMIN: {
+    EMAIL: config.get('admin.email')
+  },
+  SIGNUP: {
+    ENABLED: config.get('signup.enabled')
   }
 }
 CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
@@ -75,13 +85,74 @@ const CONSTRAINTS_FIELDS = {
     EXTNAME: [ '.mp4', '.ogv', '.webm' ],
     INFO_HASH: { min: 40, max: 40 }, // Length, infohash is 20 bytes length but we represent it in hexa so 20 * 2
     DURATION: { min: 1, max: 7200 }, // Number
-    TAGS: { min: 1, max: 3 }, // Number of total tags
+    TAGS: { min: 0, max: 3 }, // Number of total tags
     TAG: { min: 2, max: 10 }, // Length
     THUMBNAIL: { min: 2, max: 30 },
-    THUMBNAIL_DATA: { min: 0, max: 20000 } // Bytes
+    THUMBNAIL_DATA: { min: 0, max: 20000 }, // Bytes
+    VIEWS: { min: 0 },
+    LIKES: { min: 0 },
+    DISLIKES: { min: 0 }
+  },
+  VIDEO_EVENTS: {
+    COUNT: { min: 0 }
   }
 }
 
+const VIDEO_RATE_TYPES = {
+  LIKE: 'like',
+  DISLIKE: 'dislike'
+}
+
+const VIDEO_CATEGORIES = {
+  1: 'Music',
+  2: 'Films',
+  3: 'Vehicles',
+  4: 'Art',
+  5: 'Sports',
+  6: 'Travels',
+  7: 'Gaming',
+  8: 'People',
+  9: 'Comedy',
+  10: 'Entertainment',
+  11: 'News',
+  12: 'Howto',
+  13: 'Education',
+  14: 'Activism',
+  15: 'Science & Technology',
+  16: 'Animals',
+  17: 'Kids',
+  18: 'Food'
+}
+
+// See https://creativecommons.org/licenses/?lang=en
+const VIDEO_LICENCES = {
+  1: 'Attribution',
+  2: 'Attribution - Share Alike',
+  3: 'Attribution - No Derivatives',
+  4: 'Attribution - Non Commercial',
+  5: 'Attribution - Non Commercial - Share Alike',
+  6: 'Attribution - Non Commercial - No Derivatives',
+  7: 'Public Domain Dedication'
+}
+
+// See https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers#Nationalencyklopedin
+const VIDEO_LANGUAGES = {
+  1: 'English',
+  2: 'Spanish',
+  3: 'Mandarin',
+  4: 'Hindi',
+  5: 'Arabic',
+  6: 'Portuguese',
+  7: 'Bengali',
+  8: 'Russian',
+  9: 'Japanese',
+  10: 'Punjabi',
+  11: 'German',
+  12: 'Korean',
+  13: 'French',
+  14: 'Italien'
+}
+
 // ---------------------------------------------------------------------------
 
 // Score a pod has when we create it as a friend
@@ -92,10 +163,6 @@ const FRIEND_SCORE = {
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 0
-
-// ---------------------------------------------------------------------------
-
 // Number of points we add/remove from a friend after a successful/bad request
 const PODS_SCORE = {
   MALUS: -10,
@@ -113,12 +180,21 @@ const REQUESTS_LIMIT_PODS = 10
 // How many requests we send to a pod per interval
 const REQUESTS_LIMIT_PER_POD = 5
 
+const REQUESTS_VIDEO_QADU_LIMIT_PODS = 10
+// The QADU requests are not big
+const REQUESTS_VIDEO_QADU_LIMIT_PER_POD = 50
+
+const REQUESTS_VIDEO_EVENT_LIMIT_PODS = 10
+// The EVENTS requests are not big
+const REQUESTS_VIDEO_EVENT_LIMIT_PER_POD = 50
+
 // Number of requests to retry for replay requests module
 const RETRY_REQUESTS = 5
 
 const REQUEST_ENDPOINTS = {
   VIDEOS: 'videos'
 }
+
 const REQUEST_ENDPOINT_ACTIONS = {}
 REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = {
   ADD: 'add',
@@ -127,6 +203,21 @@ REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = {
   REPORT_ABUSE: 'report-abuse'
 }
 
+const REQUEST_VIDEO_QADU_ENDPOINT = 'videos/qadu'
+const REQUEST_VIDEO_EVENT_ENDPOINT = 'videos/events'
+
+const REQUEST_VIDEO_QADU_TYPES = {
+  LIKES: 'likes',
+  DISLIKES: 'dislikes',
+  VIEWS: 'views'
+}
+
+const REQUEST_VIDEO_EVENT_TYPES = {
+  LIKES: 'likes',
+  DISLIKES: 'dislikes',
+  VIEWS: 'views'
+}
+
 const REMOTE_SCHEME = {
   HTTP: 'https',
   WS: 'wss'
@@ -196,10 +287,18 @@ module.exports = {
   REMOTE_SCHEME,
   REQUEST_ENDPOINT_ACTIONS,
   REQUEST_ENDPOINTS,
+  REQUEST_VIDEO_EVENT_ENDPOINT,
+  REQUEST_VIDEO_EVENT_TYPES,
+  REQUEST_VIDEO_QADU_ENDPOINT,
+  REQUEST_VIDEO_QADU_TYPES,
   REQUESTS_IN_PARALLEL,
   REQUESTS_INTERVAL,
   REQUESTS_LIMIT_PER_POD,
   REQUESTS_LIMIT_PODS,
+  REQUESTS_VIDEO_EVENT_LIMIT_PER_POD,
+  REQUESTS_VIDEO_EVENT_LIMIT_PODS,
+  REQUESTS_VIDEO_QADU_LIMIT_PER_POD,
+  REQUESTS_VIDEO_QADU_LIMIT_PODS,
   RETRY_REQUESTS,
   SEARCHABLE_COLUMNS,
   SIGNATURE_ALGORITHM,
@@ -208,7 +307,11 @@ module.exports = {
   STATIC_MAX_AGE,
   STATIC_PATHS,
   THUMBNAILS_SIZE,
-  USER_ROLES
+  USER_ROLES,
+  VIDEO_CATEGORIES,
+  VIDEO_LANGUAGES,
+  VIDEO_LICENCES,
+  VIDEO_RATE_TYPES
 }
 
 // ---------------------------------------------------------------------------