aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/checker-before-init.ts8
-rw-r--r--server/initializers/constants.ts27
-rw-r--r--server/initializers/database.ts8
-rw-r--r--server/initializers/migrations/0120-video-null.ts3
-rw-r--r--server/initializers/migrations/0195-support.ts9
-rw-r--r--server/initializers/migrations/0245-user-blocked.ts3
-rw-r--r--server/initializers/migrations/0250-video-abuse-state.ts3
-rw-r--r--server/initializers/migrations/0255-video-blacklist-reason.ts3
-rw-r--r--server/initializers/migrations/0260-upload-quota-daily.ts1
-rw-r--r--server/initializers/migrations/0280-webtorrent-policy-user.ts28
-rw-r--r--server/initializers/migrations/0285-description-support.ts53
11 files changed, 115 insertions, 31 deletions
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 4f46d406a..9dfb5d68c 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -77,7 +77,7 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
77 } 77 }
78 } 78 }
79 79
80 checkFFmpegEncoders() 80 return checkFFmpegEncoders()
81} 81}
82 82
83// Optional encoders, if present, can be used to improve transcoding 83// Optional encoders, if present, can be used to improve transcoding
@@ -95,10 +95,10 @@ async function checkFFmpegEncoders (): Promise<Map<string, boolean>> {
95 supportedOptionalEncoders = new Map<string, boolean>() 95 supportedOptionalEncoders = new Map<string, boolean>()
96 96
97 for (const encoder of optionalEncoders) { 97 for (const encoder of optionalEncoders) {
98 supportedOptionalEncoders.set(encoder, 98 supportedOptionalEncoders.set(encoder, encoders[encoder] !== undefined)
99 encoders[encoder] !== undefined
100 )
101 } 99 }
100
101 return supportedOptionalEncoders
102} 102}
103 103
104// --------------------------------------------------------------------------- 104// ---------------------------------------------------------------------------
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index fd2308eb6..28d51068b 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -3,9 +3,9 @@ import { dirname, join } from 'path'
3import { JobType, VideoRateType, VideoState, VideosRedundancy } from '../../shared/models' 3import { JobType, VideoRateType, VideoState, VideosRedundancy } from '../../shared/models'
4import { ActivityPubActorType } from '../../shared/models/activitypub' 4import { ActivityPubActorType } from '../../shared/models/activitypub'
5import { FollowState } from '../../shared/models/actors' 5import { FollowState } from '../../shared/models/actors'
6import { VideoAbuseState, VideoImportState, VideoPrivacy } from '../../shared/models/videos' 6import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos'
7// Do not use barrels, remain constants as independent as possible 7// Do not use barrels, remain constants as independent as possible
8import { buildPath, isTestInstance, parseDuration, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' 8import { buildPath, isTestInstance, parseDuration, parseBytes, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
9import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' 9import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
10import { invert } from 'lodash' 10import { invert } from 'lodash'
11import { CronRepeatOptions, EveryRepeatOptions } from 'bull' 11import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
@@ -16,7 +16,7 @@ let config: IConfig = require('config')
16 16
17// --------------------------------------------------------------------------- 17// ---------------------------------------------------------------------------
18 18
19const LAST_MIGRATION_VERSION = 275 19const LAST_MIGRATION_VERSION = 285
20 20
21// --------------------------------------------------------------------------- 21// ---------------------------------------------------------------------------
22 22
@@ -47,7 +47,10 @@ const SORTABLE_COLUMNS = {
47 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ], 47 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ],
48 48
49 VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'match' ], 49 VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'match' ],
50 VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ] 50 VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ],
51
52 ACCOUNTS_BLOCKLIST: [ 'createdAt' ],
53 SERVERS_BLOCKLIST: [ 'createdAt' ]
51} 54}
52 55
53const OAUTH_LIFETIME = { 56const OAUTH_LIFETIME = {
@@ -232,8 +235,8 @@ const CONFIG = {
232 } 235 }
233 }, 236 },
234 USER: { 237 USER: {
235 get VIDEO_QUOTA () { return config.get<number>('user.video_quota') }, 238 get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) },
236 get VIDEO_QUOTA_DAILY () { return config.get<number>('user.video_quota_daily') } 239 get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) }
237 }, 240 },
238 TRANSCODING: { 241 TRANSCODING: {
239 get ENABLED () { return config.get<boolean>('transcoding.enabled') }, 242 get ENABLED () { return config.get<boolean>('transcoding.enabled') },
@@ -292,7 +295,7 @@ const CONFIG = {
292const CONSTRAINTS_FIELDS = { 295const CONSTRAINTS_FIELDS = {
293 USERS: { 296 USERS: {
294 NAME: { min: 3, max: 120 }, // Length 297 NAME: { min: 3, max: 120 }, // Length
295 DESCRIPTION: { min: 3, max: 250 }, // Length 298 DESCRIPTION: { min: 3, max: 1000 }, // Length
296 USERNAME: { min: 3, max: 20 }, // Length 299 USERNAME: { min: 3, max: 20 }, // Length
297 PASSWORD: { min: 6, max: 255 }, // Length 300 PASSWORD: { min: 6, max: 255 }, // Length
298 VIDEO_QUOTA: { min: -1 }, 301 VIDEO_QUOTA: { min: -1 },
@@ -308,8 +311,8 @@ const CONSTRAINTS_FIELDS = {
308 }, 311 },
309 VIDEO_CHANNELS: { 312 VIDEO_CHANNELS: {
310 NAME: { min: 3, max: 120 }, // Length 313 NAME: { min: 3, max: 120 }, // Length
311 DESCRIPTION: { min: 3, max: 500 }, // Length 314 DESCRIPTION: { min: 3, max: 1000 }, // Length
312 SUPPORT: { min: 3, max: 500 }, // Length 315 SUPPORT: { min: 3, max: 1000 }, // Length
313 URL: { min: 3, max: 2000 } // Length 316 URL: { min: 3, max: 2000 } // Length
314 }, 317 },
315 VIDEO_CAPTIONS: { 318 VIDEO_CAPTIONS: {
@@ -338,7 +341,7 @@ const CONSTRAINTS_FIELDS = {
338 LANGUAGE: { min: 1, max: 10 }, // Length 341 LANGUAGE: { min: 1, max: 10 }, // Length
339 TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length 342 TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length
340 DESCRIPTION: { min: 3, max: 10000 }, // Length 343 DESCRIPTION: { min: 3, max: 10000 }, // Length
341 SUPPORT: { min: 3, max: 500 }, // Length 344 SUPPORT: { min: 3, max: 1000 }, // Length
342 IMAGE: { 345 IMAGE: {
343 EXTNAME: [ '.jpg', '.jpeg' ], 346 EXTNAME: [ '.jpg', '.jpeg' ],
344 FILE_SIZE: { 347 FILE_SIZE: {
@@ -393,7 +396,7 @@ const RATES_LIMIT = {
393} 396}
394 397
395let VIDEO_VIEW_LIFETIME = 60000 * 60 // 1 hour 398let VIDEO_VIEW_LIFETIME = 60000 * 60 // 1 hour
396const VIDEO_TRANSCODING_FPS = { 399const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = {
397 MIN: 10, 400 MIN: 10,
398 AVERAGE: 30, 401 AVERAGE: 30,
399 MAX: 60, 402 MAX: 60,
@@ -421,7 +424,7 @@ const VIDEO_CATEGORIES = {
421 8: 'People', 424 8: 'People',
422 9: 'Comedy', 425 9: 'Comedy',
423 10: 'Entertainment', 426 10: 'Entertainment',
424 11: 'News', 427 11: 'News & Politics',
425 12: 'How To', 428 12: 'How To',
426 13: 'Education', 429 13: 'Education',
427 14: 'Activism', 430 14: 'Activism',
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index 4d57bf8aa..dd5b9bf67 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -28,6 +28,9 @@ import { VideoImportModel } from '../models/video/video-import'
28import { VideoViewModel } from '../models/video/video-views' 28import { VideoViewModel } from '../models/video/video-views'
29import { VideoChangeOwnershipModel } from '../models/video/video-change-ownership' 29import { VideoChangeOwnershipModel } from '../models/video/video-change-ownership'
30import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' 30import { VideoRedundancyModel } from '../models/redundancy/video-redundancy'
31import { UserVideoHistoryModel } from '../models/account/user-video-history'
32import { AccountBlocklistModel } from '../models/account/account-blocklist'
33import { ServerBlocklistModel } from '../models/server/server-blocklist'
31 34
32require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string 35require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string
33 36
@@ -89,7 +92,10 @@ async function initDatabaseModels (silent: boolean) {
89 ScheduleVideoUpdateModel, 92 ScheduleVideoUpdateModel,
90 VideoImportModel, 93 VideoImportModel,
91 VideoViewModel, 94 VideoViewModel,
92 VideoRedundancyModel 95 VideoRedundancyModel,
96 UserVideoHistoryModel,
97 AccountBlocklistModel,
98 ServerBlocklistModel
93 ]) 99 ])
94 100
95 // Check extensions exist in the database 101 // Check extensions exist in the database
diff --git a/server/initializers/migrations/0120-video-null.ts b/server/initializers/migrations/0120-video-null.ts
index 63f3984dd..6d253f04f 100644
--- a/server/initializers/migrations/0120-video-null.ts
+++ b/server/initializers/migrations/0120-video-null.ts
@@ -1,5 +1,4 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { CONSTRAINTS_FIELDS } from '../constants'
3 2
4async function up (utils: { 3async function up (utils: {
5 transaction: Sequelize.Transaction, 4 transaction: Sequelize.Transaction,
@@ -28,7 +27,7 @@ async function up (utils: {
28 27
29 { 28 {
30 const data = { 29 const data = {
31 type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max), 30 type: Sequelize.STRING(10000),
32 allowNull: true, 31 allowNull: true,
33 defaultValue: null 32 defaultValue: null
34 } 33 }
diff --git a/server/initializers/migrations/0195-support.ts b/server/initializers/migrations/0195-support.ts
index 8722a5f22..3b9eabe79 100644
--- a/server/initializers/migrations/0195-support.ts
+++ b/server/initializers/migrations/0195-support.ts
@@ -1,5 +1,4 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { CONSTRAINTS_FIELDS } from '../index'
3 2
4async function up (utils: { 3async function up (utils: {
5 transaction: Sequelize.Transaction, 4 transaction: Sequelize.Transaction,
@@ -8,7 +7,7 @@ async function up (utils: {
8}): Promise<void> { 7}): Promise<void> {
9 { 8 {
10 const data = { 9 const data = {
11 type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.SUPPORT.max), 10 type: Sequelize.STRING(500),
12 allowNull: true, 11 allowNull: true,
13 defaultValue: null 12 defaultValue: null
14 } 13 }
@@ -17,7 +16,7 @@ async function up (utils: {
17 16
18 { 17 {
19 const data = { 18 const data = {
20 type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max), 19 type: Sequelize.STRING(500),
21 allowNull: true, 20 allowNull: true,
22 defaultValue: null 21 defaultValue: null
23 } 22 }
@@ -26,7 +25,7 @@ async function up (utils: {
26 25
27 { 26 {
28 const data = { 27 const data = {
29 type: Sequelize.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max), 28 type: Sequelize.STRING(250),
30 allowNull: true, 29 allowNull: true,
31 defaultValue: null 30 defaultValue: null
32 } 31 }
@@ -35,7 +34,7 @@ async function up (utils: {
35 34
36 { 35 {
37 const data = { 36 const data = {
38 type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max), 37 type: Sequelize.STRING(10000),
39 allowNull: true, 38 allowNull: true,
40 defaultValue: null 39 defaultValue: null
41 } 40 }
diff --git a/server/initializers/migrations/0245-user-blocked.ts b/server/initializers/migrations/0245-user-blocked.ts
index 5a04ecd2b..19c7d5b9c 100644
--- a/server/initializers/migrations/0245-user-blocked.ts
+++ b/server/initializers/migrations/0245-user-blocked.ts
@@ -1,5 +1,4 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { CONSTRAINTS_FIELDS } from '../constants'
3 2
4async function up (utils: { 3async function up (utils: {
5 transaction: Sequelize.Transaction 4 transaction: Sequelize.Transaction
@@ -31,7 +30,7 @@ async function up (utils: {
31 30
32 { 31 {
33 const data = { 32 const data = {
34 type: Sequelize.STRING(CONSTRAINTS_FIELDS.USERS.BLOCKED_REASON.max), 33 type: Sequelize.STRING(250),
35 allowNull: true, 34 allowNull: true,
36 defaultValue: null 35 defaultValue: null
37 } 36 }
diff --git a/server/initializers/migrations/0250-video-abuse-state.ts b/server/initializers/migrations/0250-video-abuse-state.ts
index acb668ae1..50de25182 100644
--- a/server/initializers/migrations/0250-video-abuse-state.ts
+++ b/server/initializers/migrations/0250-video-abuse-state.ts
@@ -1,5 +1,4 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { CONSTRAINTS_FIELDS } from '../constants'
3import { VideoAbuseState } from '../../../shared/models/videos' 2import { VideoAbuseState } from '../../../shared/models/videos'
4 3
5async function up (utils: { 4async function up (utils: {
@@ -32,7 +31,7 @@ async function up (utils: {
32 31
33 { 32 {
34 const data = { 33 const data = {
35 type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_ABUSES.MODERATION_COMMENT.max), 34 type: Sequelize.STRING(300),
36 allowNull: true, 35 allowNull: true,
37 defaultValue: null 36 defaultValue: null
38 } 37 }
diff --git a/server/initializers/migrations/0255-video-blacklist-reason.ts b/server/initializers/migrations/0255-video-blacklist-reason.ts
index a380e620e..69d6efb9e 100644
--- a/server/initializers/migrations/0255-video-blacklist-reason.ts
+++ b/server/initializers/migrations/0255-video-blacklist-reason.ts
@@ -1,5 +1,4 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { CONSTRAINTS_FIELDS } from '../constants'
3import { VideoAbuseState } from '../../../shared/models/videos' 2import { VideoAbuseState } from '../../../shared/models/videos'
4 3
5async function up (utils: { 4async function up (utils: {
@@ -10,7 +9,7 @@ async function up (utils: {
10 9
11 { 10 {
12 const data = { 11 const data = {
13 type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_BLACKLIST.REASON.max), 12 type: Sequelize.STRING(300),
14 allowNull: true, 13 allowNull: true,
15 defaultValue: null 14 defaultValue: null
16 } 15 }
diff --git a/server/initializers/migrations/0260-upload-quota-daily.ts b/server/initializers/migrations/0260-upload-quota-daily.ts
index d25154ba6..cbbe391ef 100644
--- a/server/initializers/migrations/0260-upload-quota-daily.ts
+++ b/server/initializers/migrations/0260-upload-quota-daily.ts
@@ -1,5 +1,4 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { CONSTRAINTS_FIELDS } from '../constants'
3 2
4async function up (utils: { 3async function up (utils: {
5 transaction: Sequelize.Transaction 4 transaction: Sequelize.Transaction
diff --git a/server/initializers/migrations/0280-webtorrent-policy-user.ts b/server/initializers/migrations/0280-webtorrent-policy-user.ts
new file mode 100644
index 000000000..e6488356a
--- /dev/null
+++ b/server/initializers/migrations/0280-webtorrent-policy-user.ts
@@ -0,0 +1,28 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7}): Promise<any> {
8 {
9 const data = {
10 type: Sequelize.BOOLEAN,
11 allowNull: false,
12 defaultValue: true
13 }
14
15 await utils.queryInterface.addColumn('user', 'webTorrentEnabled', data)
16 }
17
18}
19
20async function down (utils: {
21 transaction: Sequelize.Transaction
22 queryInterface: Sequelize.QueryInterface
23 sequelize: Sequelize.Sequelize
24}): Promise<any> {
25 await utils.queryInterface.removeColumn('user', 'webTorrentEnabled')
26}
27
28export { up, down }
diff --git a/server/initializers/migrations/0285-description-support.ts b/server/initializers/migrations/0285-description-support.ts
new file mode 100644
index 000000000..85ef4ef39
--- /dev/null
+++ b/server/initializers/migrations/0285-description-support.ts
@@ -0,0 +1,53 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction,
5 queryInterface: Sequelize.QueryInterface,
6 sequelize: Sequelize.Sequelize,
7 db: any
8}): Promise<void> {
9 {
10 const data = {
11 type: Sequelize.STRING(1000),
12 allowNull: true,
13 defaultValue: null
14 }
15 await utils.queryInterface.changeColumn('video', 'support', data)
16 }
17
18 {
19 const data = {
20 type: Sequelize.STRING(1000),
21 allowNull: true,
22 defaultValue: null
23 }
24 await utils.queryInterface.changeColumn('videoChannel', 'support', data)
25 }
26
27 {
28 const data = {
29 type: Sequelize.STRING(1000),
30 allowNull: true,
31 defaultValue: null
32 }
33 await utils.queryInterface.changeColumn('videoChannel', 'description', data)
34 }
35
36 {
37 const data = {
38 type: Sequelize.STRING(1000),
39 allowNull: true,
40 defaultValue: null
41 }
42 await utils.queryInterface.changeColumn('account', 'description', data)
43 }
44}
45
46function down (options) {
47 throw new Error('Not implemented.')
48}
49
50export {
51 up,
52 down
53}