diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-15 15:58:10 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-16 10:08:55 +0100 |
commit | a9bfa85d2cdf13670aaced740da5b493fbeddfce (patch) | |
tree | 3781c9218d4cc7786b6589365c0efbed2151703d /server/controllers | |
parent | c77fdc605b3ccc1ab6890f889d8200fbe9372949 (diff) | |
download | PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.gz PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.zst PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.zip |
Add ability for admins to set default p2p policy
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/users/index.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/users/me.ts | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index 11d3525e4..f3b4508d9 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -183,6 +183,7 @@ async function createUser (req: express.Request, res: express.Response) { | |||
183 | password: body.password, | 183 | password: body.password, |
184 | email: body.email, | 184 | email: body.email, |
185 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, | 185 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, |
186 | p2pEnabled: CONFIG.DEFAULTS.P2P.ENABLED, | ||
186 | autoPlayVideo: true, | 187 | autoPlayVideo: true, |
187 | role: body.role, | 188 | role: body.role, |
188 | videoQuota: body.videoQuota, | 189 | videoQuota: body.videoQuota, |
@@ -232,6 +233,7 @@ async function registerUser (req: express.Request, res: express.Response) { | |||
232 | password: body.password, | 233 | password: body.password, |
233 | email: body.email, | 234 | email: body.email, |
234 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, | 235 | nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, |
236 | p2pEnabled: CONFIG.DEFAULTS.P2P.ENABLED, | ||
235 | autoPlayVideo: true, | 237 | autoPlayVideo: true, |
236 | role: UserRole.USER, | 238 | role: UserRole.USER, |
237 | videoQuota: CONFIG.USER.VIDEO_QUOTA, | 239 | videoQuota: CONFIG.USER.VIDEO_QUOTA, |
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 6bacdbbb6..1125771d4 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -197,7 +197,7 @@ async function updateMe (req: express.Request, res: express.Response) { | |||
197 | const keysToUpdate: (keyof UserUpdateMe & keyof AttributesOnly<UserModel>)[] = [ | 197 | const keysToUpdate: (keyof UserUpdateMe & keyof AttributesOnly<UserModel>)[] = [ |
198 | 'password', | 198 | 'password', |
199 | 'nsfwPolicy', | 199 | 'nsfwPolicy', |
200 | 'webTorrentEnabled', | 200 | 'p2pEnabled', |
201 | 'autoPlayVideo', | 201 | 'autoPlayVideo', |
202 | 'autoPlayNextVideo', | 202 | 'autoPlayNextVideo', |
203 | 'autoPlayNextVideoPlaylist', | 203 | 'autoPlayNextVideoPlaylist', |
@@ -213,6 +213,12 @@ async function updateMe (req: express.Request, res: express.Response) { | |||
213 | if (body[key] !== undefined) user.set(key, body[key]) | 213 | if (body[key] !== undefined) user.set(key, body[key]) |
214 | } | 214 | } |
215 | 215 | ||
216 | if (body.p2pEnabled !== undefined) { | ||
217 | user.set('p2pEnabled', body.p2pEnabled) | ||
218 | } else if (body.webTorrentEnabled !== undefined) { // FIXME: deprecated in 4.1 | ||
219 | user.set('p2pEnabled', body.webTorrentEnabled) | ||
220 | } | ||
221 | |||
216 | if (body.email !== undefined) { | 222 | if (body.email !== undefined) { |
217 | if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { | 223 | if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { |
218 | user.pendingEmail = body.email | 224 | user.pendingEmail = body.email |