diff options
Diffstat (limited to 'server/initializers/constants.js')
-rw-r--r-- | server/initializers/constants.js | 83 |
1 files changed, 32 insertions, 51 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js index 3ddf87454..97e3c5296 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js | |||
@@ -1,7 +1,6 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const config = require('config') | 3 | const config = require('config') |
4 | const maxBy = require('lodash/maxBy') | ||
5 | const path = require('path') | 4 | const path = require('path') |
6 | 5 | ||
7 | // --------------------------------------------------------------------------- | 6 | // --------------------------------------------------------------------------- |
@@ -14,13 +13,14 @@ const PAGINATION_COUNT_DEFAULT = 15 | |||
14 | 13 | ||
15 | // Sortable columns per schema | 14 | // Sortable columns per schema |
16 | const SEARCHABLE_COLUMNS = { | 15 | const SEARCHABLE_COLUMNS = { |
17 | VIDEOS: [ 'name', 'magnetUri', 'podHost', 'author', 'tags' ] | 16 | VIDEOS: [ 'name', 'magnetUri', 'host', 'author', 'tags' ] |
18 | } | 17 | } |
19 | 18 | ||
20 | // Sortable columns per schema | 19 | // Sortable columns per schema |
21 | const SORTABLE_COLUMNS = { | 20 | const SORTABLE_COLUMNS = { |
22 | USERS: [ 'username', '-username', 'createdDate', '-createdDate' ], | 21 | USERS: [ 'username', '-username', 'createdAt', '-createdAt' ], |
23 | VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ] | 22 | VIDEO_ABUSES: [ 'createdAt', '-createdAt' ], |
23 | VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdAt', '-createdAt' ] | ||
24 | } | 24 | } |
25 | 25 | ||
26 | const OAUTH_LIFETIME = { | 26 | const OAUTH_LIFETIME = { |
@@ -37,7 +37,9 @@ const CONFIG = { | |||
37 | DATABASE: { | 37 | DATABASE: { |
38 | DBNAME: 'peertube' + config.get('database.suffix'), | 38 | DBNAME: 'peertube' + config.get('database.suffix'), |
39 | HOSTNAME: config.get('database.hostname'), | 39 | HOSTNAME: config.get('database.hostname'), |
40 | PORT: config.get('database.port') | 40 | PORT: config.get('database.port'), |
41 | USERNAME: config.get('database.username'), | ||
42 | PASSWORD: config.get('database.password') | ||
41 | }, | 43 | }, |
42 | STORAGE: { | 44 | STORAGE: { |
43 | CERT_DIR: path.join(__dirname, '..', '..', config.get('storage.certs')), | 45 | CERT_DIR: path.join(__dirname, '..', '..', config.get('storage.certs')), |
@@ -64,17 +66,19 @@ const CONSTRAINTS_FIELDS = { | |||
64 | USERNAME: { min: 3, max: 20 }, // Length | 66 | USERNAME: { min: 3, max: 20 }, // Length |
65 | PASSWORD: { min: 6, max: 255 } // Length | 67 | PASSWORD: { min: 6, max: 255 } // Length |
66 | }, | 68 | }, |
69 | VIDEO_ABUSES: { | ||
70 | REASON: { min: 2, max: 300 } // Length | ||
71 | }, | ||
67 | VIDEOS: { | 72 | VIDEOS: { |
68 | NAME: { min: 3, max: 50 }, // Length | 73 | NAME: { min: 3, max: 50 }, // Length |
69 | DESCRIPTION: { min: 3, max: 250 }, // Length | 74 | DESCRIPTION: { min: 3, max: 250 }, // Length |
70 | MAGNET: { | 75 | EXTNAME: [ '.mp4', '.ogv', '.webm' ], |
71 | INFO_HASH: { min: 10, max: 50 } // Length | 76 | INFO_HASH: { min: 40, max: 40 }, // Length, infohash is 20 bytes length but we represent it in hexa so 20 * 2 |
72 | }, | ||
73 | DURATION: { min: 1, max: 7200 }, // Number | 77 | DURATION: { min: 1, max: 7200 }, // Number |
74 | TAGS: { min: 1, max: 3 }, // Number of total tags | 78 | TAGS: { min: 1, max: 3 }, // Number of total tags |
75 | TAG: { min: 2, max: 10 }, // Length | 79 | TAG: { min: 2, max: 10 }, // Length |
76 | THUMBNAIL: { min: 2, max: 30 }, | 80 | THUMBNAIL: { min: 2, max: 30 }, |
77 | THUMBNAIL64: { min: 0, max: 20000 } // Bytes | 81 | THUMBNAIL_DATA: { min: 0, max: 20000 } // Bytes |
78 | } | 82 | } |
79 | } | 83 | } |
80 | 84 | ||
@@ -88,41 +92,7 @@ const FRIEND_SCORE = { | |||
88 | 92 | ||
89 | // --------------------------------------------------------------------------- | 93 | // --------------------------------------------------------------------------- |
90 | 94 | ||
91 | const MONGO_MIGRATION_SCRIPTS = [ | 95 | const LAST_MIGRATION_VERSION = 0 |
92 | { | ||
93 | script: '0005-create-application', | ||
94 | version: 5 | ||
95 | }, | ||
96 | { | ||
97 | script: '0010-users-password', | ||
98 | version: 10 | ||
99 | }, | ||
100 | { | ||
101 | script: '0015-admin-role', | ||
102 | version: 15 | ||
103 | }, | ||
104 | { | ||
105 | script: '0020-requests-endpoint', | ||
106 | version: 20 | ||
107 | }, | ||
108 | { | ||
109 | script: '0025-video-filenames', | ||
110 | version: 25 | ||
111 | }, | ||
112 | { | ||
113 | script: '0030-video-magnet', | ||
114 | version: 30 | ||
115 | }, | ||
116 | { | ||
117 | script: '0035-url-to-host', | ||
118 | version: 35 | ||
119 | }, | ||
120 | { | ||
121 | script: '0040-video-remote-id', | ||
122 | version: 40 | ||
123 | } | ||
124 | ] | ||
125 | const LAST_MONGO_SCHEMA_VERSION = (maxBy(MONGO_MIGRATION_SCRIPTS, 'version'))['version'] | ||
126 | 96 | ||
127 | // --------------------------------------------------------------------------- | 97 | // --------------------------------------------------------------------------- |
128 | 98 | ||
@@ -138,8 +108,10 @@ let REQUESTS_INTERVAL = 600000 | |||
138 | // Number of requests in parallel we can make | 108 | // Number of requests in parallel we can make |
139 | const REQUESTS_IN_PARALLEL = 10 | 109 | const REQUESTS_IN_PARALLEL = 10 |
140 | 110 | ||
141 | // How many requests we put in request | 111 | // To how many pods we send requests |
142 | const REQUESTS_LIMIT = 10 | 112 | const REQUESTS_LIMIT_PODS = 10 |
113 | // How many requests we send to a pod per interval | ||
114 | const REQUESTS_LIMIT_PER_POD = 5 | ||
143 | 115 | ||
144 | // Number of requests to retry for replay requests module | 116 | // Number of requests to retry for replay requests module |
145 | const RETRY_REQUESTS = 5 | 117 | const RETRY_REQUESTS = 5 |
@@ -148,16 +120,21 @@ const REQUEST_ENDPOINTS = { | |||
148 | VIDEOS: 'videos' | 120 | VIDEOS: 'videos' |
149 | } | 121 | } |
150 | 122 | ||
151 | // --------------------------------------------------------------------------- | ||
152 | |||
153 | const REMOTE_SCHEME = { | 123 | const REMOTE_SCHEME = { |
154 | HTTP: 'https', | 124 | HTTP: 'https', |
155 | WS: 'wss' | 125 | WS: 'wss' |
156 | } | 126 | } |
157 | 127 | ||
128 | // --------------------------------------------------------------------------- | ||
129 | |||
130 | const SIGNATURE_ALGORITHM = 'RSA-SHA256' | ||
131 | const SIGNATURE_ENCODING = 'hex' | ||
132 | |||
158 | // Password encryption | 133 | // Password encryption |
159 | const BCRYPT_SALT_SIZE = 10 | 134 | const BCRYPT_SALT_SIZE = 10 |
160 | 135 | ||
136 | // --------------------------------------------------------------------------- | ||
137 | |||
161 | // Express static paths (router) | 138 | // Express static paths (router) |
162 | const STATIC_PATHS = { | 139 | const STATIC_PATHS = { |
163 | PREVIEWS: '/static/previews/', | 140 | PREVIEWS: '/static/previews/', |
@@ -173,6 +150,8 @@ let STATIC_MAX_AGE = '30d' | |||
173 | const THUMBNAILS_SIZE = '200x110' | 150 | const THUMBNAILS_SIZE = '200x110' |
174 | const PREVIEWS_SIZE = '640x480' | 151 | const PREVIEWS_SIZE = '640x480' |
175 | 152 | ||
153 | // --------------------------------------------------------------------------- | ||
154 | |||
176 | const USER_ROLES = { | 155 | const USER_ROLES = { |
177 | ADMIN: 'admin', | 156 | ADMIN: 'admin', |
178 | USER: 'user' | 157 | USER: 'user' |
@@ -198,8 +177,7 @@ module.exports = { | |||
198 | CONFIG, | 177 | CONFIG, |
199 | CONSTRAINTS_FIELDS, | 178 | CONSTRAINTS_FIELDS, |
200 | FRIEND_SCORE, | 179 | FRIEND_SCORE, |
201 | LAST_MONGO_SCHEMA_VERSION, | 180 | LAST_MIGRATION_VERSION, |
202 | MONGO_MIGRATION_SCRIPTS, | ||
203 | OAUTH_LIFETIME, | 181 | OAUTH_LIFETIME, |
204 | PAGINATION_COUNT_DEFAULT, | 182 | PAGINATION_COUNT_DEFAULT, |
205 | PODS_SCORE, | 183 | PODS_SCORE, |
@@ -208,9 +186,12 @@ module.exports = { | |||
208 | REQUEST_ENDPOINTS, | 186 | REQUEST_ENDPOINTS, |
209 | REQUESTS_IN_PARALLEL, | 187 | REQUESTS_IN_PARALLEL, |
210 | REQUESTS_INTERVAL, | 188 | REQUESTS_INTERVAL, |
211 | REQUESTS_LIMIT, | 189 | REQUESTS_LIMIT_PODS, |
190 | REQUESTS_LIMIT_PER_POD, | ||
212 | RETRY_REQUESTS, | 191 | RETRY_REQUESTS, |
213 | SEARCHABLE_COLUMNS, | 192 | SEARCHABLE_COLUMNS, |
193 | SIGNATURE_ALGORITHM, | ||
194 | SIGNATURE_ENCODING, | ||
214 | SORTABLE_COLUMNS, | 195 | SORTABLE_COLUMNS, |
215 | STATIC_MAX_AGE, | 196 | STATIC_MAX_AGE, |
216 | STATIC_PATHS, | 197 | STATIC_PATHS, |