diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-11 09:21:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-11 09:21:13 +0200 |
commit | 784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428 (patch) | |
tree | 29c46cfd6344065eb805680ed080cb05592ee1d4 /server/controllers/api | |
parent | c3030e944ad03c7fd7b5d668a2d88ff03e4cdf19 (diff) | |
download | PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.tar.gz PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.tar.zst PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.zip |
Prefer web videos in favour of webtorrent
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/runners/jobs-files.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/users/me.ts | 9 | ||||
-rw-r--r-- | server/controllers/api/videos/files.ts | 34 |
3 files changed, 22 insertions, 25 deletions
diff --git a/server/controllers/api/runners/jobs-files.ts b/server/controllers/api/runners/jobs-files.ts index 4e69fb902..cb4eff570 100644 --- a/server/controllers/api/runners/jobs-files.ts +++ b/server/controllers/api/runners/jobs-files.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 2 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
3 | import { proxifyHLS, proxifyWebTorrentFile } from '@server/lib/object-storage' | 3 | import { proxifyHLS, proxifyWebVideoFile } from '@server/lib/object-storage' |
4 | import { VideoPathManager } from '@server/lib/video-path-manager' | 4 | import { VideoPathManager } from '@server/lib/video-path-manager' |
5 | import { getStudioTaskFilePath } from '@server/lib/video-studio' | 5 | import { getStudioTaskFilePath } from '@server/lib/video-studio' |
6 | import { apiRateLimiter, asyncMiddleware } from '@server/middlewares' | 6 | import { apiRateLimiter, asyncMiddleware } from '@server/middlewares' |
@@ -70,7 +70,7 @@ async function getMaxQualityVideoFile (req: express.Request, res: express.Respon | |||
70 | } | 70 | } |
71 | 71 | ||
72 | // Web video | 72 | // Web video |
73 | return proxifyWebTorrentFile({ | 73 | return proxifyWebVideoFile({ |
74 | req, | 74 | req, |
75 | res, | 75 | res, |
76 | filename: file.filename | 76 | filename: file.filename |
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 218091d91..4753308e8 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -213,19 +213,14 @@ async function updateMe (req: express.Request, res: express.Response) { | |||
213 | 'noInstanceConfigWarningModal', | 213 | 'noInstanceConfigWarningModal', |
214 | 'noAccountSetupWarningModal', | 214 | 'noAccountSetupWarningModal', |
215 | 'noWelcomeModal', | 215 | 'noWelcomeModal', |
216 | 'emailPublic' | 216 | 'emailPublic', |
217 | 'p2pEnabled' | ||
217 | ] | 218 | ] |
218 | 219 | ||
219 | for (const key of keysToUpdate) { | 220 | for (const key of keysToUpdate) { |
220 | if (body[key] !== undefined) user.set(key, body[key]) | 221 | if (body[key] !== undefined) user.set(key, body[key]) |
221 | } | 222 | } |
222 | 223 | ||
223 | if (body.p2pEnabled !== undefined) { | ||
224 | user.set('p2pEnabled', body.p2pEnabled) | ||
225 | } else if (body.webTorrentEnabled !== undefined) { // FIXME: deprecated in 4.1 | ||
226 | user.set('p2pEnabled', body.webTorrentEnabled) | ||
227 | } | ||
228 | |||
229 | if (body.email !== undefined) { | 224 | if (body.email !== undefined) { |
230 | if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { | 225 | if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { |
231 | user.pendingEmail = body.email | 226 | user.pendingEmail = body.email |
diff --git a/server/controllers/api/videos/files.ts b/server/controllers/api/videos/files.ts index 6d9c0b843..67b60ff63 100644 --- a/server/controllers/api/videos/files.ts +++ b/server/controllers/api/videos/files.ts | |||
@@ -2,7 +2,8 @@ import express from 'express' | |||
2 | import toInt from 'validator/lib/toInt' | 2 | import toInt from 'validator/lib/toInt' |
3 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 3 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
4 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' | 4 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' |
5 | import { removeAllWebTorrentFiles, removeHLSFile, removeHLSPlaylist, removeWebTorrentFile } from '@server/lib/video-file' | 5 | import { updatePlaylistAfterFileChange } from '@server/lib/hls' |
6 | import { removeAllWebVideoFiles, removeHLSFile, removeHLSPlaylist, removeWebVideoFile } from '@server/lib/video-file' | ||
6 | import { VideoFileModel } from '@server/models/video/video-file' | 7 | import { VideoFileModel } from '@server/models/video/video-file' |
7 | import { HttpStatusCode, UserRight } from '@shared/models' | 8 | import { HttpStatusCode, UserRight } from '@shared/models' |
8 | import { | 9 | import { |
@@ -12,11 +13,10 @@ import { | |||
12 | videoFileMetadataGetValidator, | 13 | videoFileMetadataGetValidator, |
13 | videoFilesDeleteHLSFileValidator, | 14 | videoFilesDeleteHLSFileValidator, |
14 | videoFilesDeleteHLSValidator, | 15 | videoFilesDeleteHLSValidator, |
15 | videoFilesDeleteWebTorrentFileValidator, | 16 | videoFilesDeleteWebVideoFileValidator, |
16 | videoFilesDeleteWebTorrentValidator, | 17 | videoFilesDeleteWebVideoValidator, |
17 | videosGetValidator | 18 | videosGetValidator |
18 | } from '../../../middlewares' | 19 | } from '../../../middlewares' |
19 | import { updatePlaylistAfterFileChange } from '@server/lib/hls' | ||
20 | 20 | ||
21 | const lTags = loggerTagsFactory('api', 'video') | 21 | const lTags = loggerTagsFactory('api', 'video') |
22 | const filesRouter = express.Router() | 22 | const filesRouter = express.Router() |
@@ -40,17 +40,19 @@ filesRouter.delete('/:id/hls/:videoFileId', | |||
40 | asyncMiddleware(removeHLSFileController) | 40 | asyncMiddleware(removeHLSFileController) |
41 | ) | 41 | ) |
42 | 42 | ||
43 | filesRouter.delete('/:id/webtorrent', | 43 | filesRouter.delete( |
44 | [ '/:id/webtorrent', '/:id/web-videos' ], // TODO: remove webtorrent in V7 | ||
44 | authenticate, | 45 | authenticate, |
45 | ensureUserHasRight(UserRight.MANAGE_VIDEO_FILES), | 46 | ensureUserHasRight(UserRight.MANAGE_VIDEO_FILES), |
46 | asyncMiddleware(videoFilesDeleteWebTorrentValidator), | 47 | asyncMiddleware(videoFilesDeleteWebVideoValidator), |
47 | asyncMiddleware(removeAllWebTorrentFilesController) | 48 | asyncMiddleware(removeAllWebVideoFilesController) |
48 | ) | 49 | ) |
49 | filesRouter.delete('/:id/webtorrent/:videoFileId', | 50 | filesRouter.delete( |
51 | [ '/:id/webtorrent/:videoFileId', '/:id/web-videos/:videoFileId' ], // TODO: remove webtorrent in V7 | ||
50 | authenticate, | 52 | authenticate, |
51 | ensureUserHasRight(UserRight.MANAGE_VIDEO_FILES), | 53 | ensureUserHasRight(UserRight.MANAGE_VIDEO_FILES), |
52 | asyncMiddleware(videoFilesDeleteWebTorrentFileValidator), | 54 | asyncMiddleware(videoFilesDeleteWebVideoFileValidator), |
53 | asyncMiddleware(removeWebTorrentFileController) | 55 | asyncMiddleware(removeWebVideoFileController) |
54 | ) | 56 | ) |
55 | 57 | ||
56 | // --------------------------------------------------------------------------- | 58 | // --------------------------------------------------------------------------- |
@@ -96,24 +98,24 @@ async function removeHLSFileController (req: express.Request, res: express.Respo | |||
96 | 98 | ||
97 | // --------------------------------------------------------------------------- | 99 | // --------------------------------------------------------------------------- |
98 | 100 | ||
99 | async function removeAllWebTorrentFilesController (req: express.Request, res: express.Response) { | 101 | async function removeAllWebVideoFilesController (req: express.Request, res: express.Response) { |
100 | const video = res.locals.videoAll | 102 | const video = res.locals.videoAll |
101 | 103 | ||
102 | logger.info('Deleting WebTorrent files of %s.', video.url, lTags(video.uuid)) | 104 | logger.info('Deleting Web Video files of %s.', video.url, lTags(video.uuid)) |
103 | 105 | ||
104 | await removeAllWebTorrentFiles(video) | 106 | await removeAllWebVideoFiles(video) |
105 | await federateVideoIfNeeded(video, false, undefined) | 107 | await federateVideoIfNeeded(video, false, undefined) |
106 | 108 | ||
107 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 109 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) |
108 | } | 110 | } |
109 | 111 | ||
110 | async function removeWebTorrentFileController (req: express.Request, res: express.Response) { | 112 | async function removeWebVideoFileController (req: express.Request, res: express.Response) { |
111 | const video = res.locals.videoAll | 113 | const video = res.locals.videoAll |
112 | 114 | ||
113 | const videoFileId = +req.params.videoFileId | 115 | const videoFileId = +req.params.videoFileId |
114 | logger.info('Deleting WebTorrent file %d of %s.', videoFileId, video.url, lTags(video.uuid)) | 116 | logger.info('Deleting Web Video file %d of %s.', videoFileId, video.url, lTags(video.uuid)) |
115 | 117 | ||
116 | await removeWebTorrentFile(video, videoFileId) | 118 | await removeWebVideoFile(video, videoFileId) |
117 | await federateVideoIfNeeded(video, false, undefined) | 119 | await federateVideoIfNeeded(video, false, undefined) |
118 | 120 | ||
119 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 121 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) |