aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts10
-rw-r--r--server/initializers/migrations/0280-webtorrent-policy-user.ts26
2 files changed, 35 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index e08fd75cd..f56763a16 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -7,6 +7,7 @@ import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS }
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, parseBytes, 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 { WebTorrentPolicyType } from '../../shared/models/users/user-webtorrent-policy.type'
10import { invert } from 'lodash' 11import { invert } from 'lodash'
11import { CronRepeatOptions, EveryRepeatOptions } from 'bull' 12import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
12import * as bytes from 'bytes' 13import * as bytes from 'bytes'
@@ -16,7 +17,7 @@ let config: IConfig = require('config')
16 17
17// --------------------------------------------------------------------------- 18// ---------------------------------------------------------------------------
18 19
19const LAST_MIGRATION_VERSION = 275 20const LAST_MIGRATION_VERSION = 280
20 21
21// --------------------------------------------------------------------------- 22// ---------------------------------------------------------------------------
22 23
@@ -546,6 +547,12 @@ const NSFW_POLICY_TYPES: { [ id: string]: NSFWPolicyType } = {
546 DISPLAY: 'display' 547 DISPLAY: 'display'
547} 548}
548 549
550const WEBTORRENT_POLICY_TYPES: { [ id: string]: WebTorrentPolicyType } = {
551 ENABLE: 'enable',
552 DISABLE: 'disable',
553 DISABLE_ON_MOBILE: 'disable_on_mobile'
554}
555
549// --------------------------------------------------------------------------- 556// ---------------------------------------------------------------------------
550 557
551// Express static paths (router) 558// Express static paths (router)
@@ -698,6 +705,7 @@ export {
698 FEEDS, 705 FEEDS,
699 JOB_TTL, 706 JOB_TTL,
700 NSFW_POLICY_TYPES, 707 NSFW_POLICY_TYPES,
708 WEBTORRENT_POLICY_TYPES,
701 TORRENT_MIMETYPE_EXT, 709 TORRENT_MIMETYPE_EXT,
702 STATIC_MAX_AGE, 710 STATIC_MAX_AGE,
703 STATIC_PATHS, 711 STATIC_PATHS,
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..d24f6709e
--- /dev/null
+++ b/server/initializers/migrations/0280-webtorrent-policy-user.ts
@@ -0,0 +1,26 @@
1import * as Sequelize from 'sequelize'
2import { values } from 'lodash'
3import { WEBTORRENT_POLICY_TYPES } from '../constants'
4
5async function up (utils: {
6 transaction: Sequelize.Transaction
7 queryInterface: Sequelize.QueryInterface
8 sequelize: Sequelize.Sequelize
9}): Promise<any> {
10 {
11 const data = {
12 type: Sequelize.ENUM(values(WEBTORRENT_POLICY_TYPES)),
13 allowNull: false,
14 defaultValue: 'enable'
15 }
16
17 await utils.queryInterface.addColumn('user', 'webTorrentPolicy', data)
18 }
19
20}
21
22function down (options) {
23 throw new Error('Not implemented.')
24}
25
26export { up, down }