]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/users/me.ts
Add ability for admins to set default p2p policy
[github/Chocobozzz/PeerTube.git] / server / controllers / api / users / me.ts
index 6bacdbbb63693702ee38423e4409fea48e90f8c7..1125771d44354315fdc50df131e0146f43250781 100644 (file)
@@ -197,7 +197,7 @@ async function updateMe (req: express.Request, res: express.Response) {
   const keysToUpdate: (keyof UserUpdateMe & keyof AttributesOnly<UserModel>)[] = [
     'password',
     'nsfwPolicy',
-    'webTorrentEnabled',
+    'p2pEnabled',
     'autoPlayVideo',
     'autoPlayNextVideo',
     'autoPlayNextVideoPlaylist',
@@ -213,6 +213,12 @@ async function updateMe (req: express.Request, res: express.Response) {
     if (body[key] !== undefined) user.set(key, body[key])
   }
 
+  if (body.p2pEnabled !== undefined) {
+    user.set('p2pEnabled', body.p2pEnabled)
+  } else if (body.webTorrentEnabled !== undefined) { // FIXME: deprecated in 4.1
+    user.set('p2pEnabled', body.webTorrentEnabled)
+  }
+
   if (body.email !== undefined) {
     if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) {
       user.pendingEmail = body.email