aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-15 15:58:10 +0100
committerChocobozzz <me@florianbigard.com>2021-12-16 10:08:55 +0100
commita9bfa85d2cdf13670aaced740da5b493fbeddfce (patch)
tree3781c9218d4cc7786b6589365c0efbed2151703d /server/initializers
parentc77fdc605b3ccc1ab6890f889d8200fbe9372949 (diff)
downloadPeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.gz
PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.zst
PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.zip
Add ability for admins to set default p2p policy
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/config.ts3
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/installer.ts1
-rw-r--r--server/initializers/migrations/0675-p2p-enabled.ts21
4 files changed, 26 insertions, 1 deletions
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index e3e8c426e..a6ea6d888 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -78,6 +78,9 @@ const CONFIG = {
78 COMMENTS_ENABLED: config.get<boolean>('defaults.publish.comments_enabled'), 78 COMMENTS_ENABLED: config.get<boolean>('defaults.publish.comments_enabled'),
79 PRIVACY: config.get<VideoPrivacy>('defaults.publish.privacy'), 79 PRIVACY: config.get<VideoPrivacy>('defaults.publish.privacy'),
80 LICENCE: config.get<number>('defaults.publish.licence') 80 LICENCE: config.get<number>('defaults.publish.licence')
81 },
82 P2P: {
83 ENABLED: config.get<boolean>('defaults.p2p.enabled')
81 } 84 }
82 }, 85 },
83 86
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 026c715c2..258ccdb51 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -25,7 +25,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
25 25
26// --------------------------------------------------------------------------- 26// ---------------------------------------------------------------------------
27 27
28const LAST_MIGRATION_VERSION = 670 28const LAST_MIGRATION_VERSION = 675
29 29
30// --------------------------------------------------------------------------- 30// ---------------------------------------------------------------------------
31 31
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 75daeb5d8..19adaf177 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -144,6 +144,7 @@ async function createOAuthAdminIfNotExist () {
144 role, 144 role,
145 verified: true, 145 verified: true,
146 nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, 146 nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
147 p2pEnabled: CONFIG.DEFAULTS.P2P.ENABLED,
147 videoQuota: -1, 148 videoQuota: -1,
148 videoQuotaDaily: -1 149 videoQuotaDaily: -1
149 } 150 }
diff --git a/server/initializers/migrations/0675-p2p-enabled.ts b/server/initializers/migrations/0675-p2p-enabled.ts
new file mode 100644
index 000000000..b4f53381e
--- /dev/null
+++ b/server/initializers/migrations/0675-p2p-enabled.ts
@@ -0,0 +1,21 @@
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 await utils.queryInterface.renameColumn('user', 'webTorrentEnabled', 'p2pEnabled')
10
11 await utils.sequelize.query('ALTER TABLE "user" ALTER COLUMN "p2pEnabled" DROP DEFAULT')
12}
13
14function down (options) {
15 throw new Error('Not implemented.')
16}
17
18export {
19 up,
20 down
21}