aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/videos')
-rw-r--r--server/middlewares/validators/videos/video-files.ts26
-rw-r--r--server/middlewares/validators/videos/videos.ts6
2 files changed, 18 insertions, 14 deletions
diff --git a/server/middlewares/validators/videos/video-files.ts b/server/middlewares/validators/videos/video-files.ts
index 92c5b9483..6c0ecda42 100644
--- a/server/middlewares/validators/videos/video-files.ts
+++ b/server/middlewares/validators/videos/video-files.ts
@@ -5,7 +5,7 @@ import { MVideo } from '@server/types/models'
5import { HttpStatusCode } from '@shared/models' 5import { HttpStatusCode } from '@shared/models'
6import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' 6import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'
7 7
8const videoFilesDeleteWebTorrentValidator = [ 8const videoFilesDeleteWebVideoValidator = [
9 isValidVideoIdParam('id'), 9 isValidVideoIdParam('id'),
10 10
11 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 11 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
@@ -16,17 +16,17 @@ const videoFilesDeleteWebTorrentValidator = [
16 16
17 if (!checkLocalVideo(video, res)) return 17 if (!checkLocalVideo(video, res)) return
18 18
19 if (!video.hasWebTorrentFiles()) { 19 if (!video.hasWebVideoFiles()) {
20 return res.fail({ 20 return res.fail({
21 status: HttpStatusCode.BAD_REQUEST_400, 21 status: HttpStatusCode.BAD_REQUEST_400,
22 message: 'This video does not have WebTorrent files' 22 message: 'This video does not have Web Video files'
23 }) 23 })
24 } 24 }
25 25
26 if (!video.getHLSPlaylist()) { 26 if (!video.getHLSPlaylist()) {
27 return res.fail({ 27 return res.fail({
28 status: HttpStatusCode.BAD_REQUEST_400, 28 status: HttpStatusCode.BAD_REQUEST_400,
29 message: 'Cannot delete WebTorrent files since this video does not have HLS playlist' 29 message: 'Cannot delete Web Video files since this video does not have HLS playlist'
30 }) 30 })
31 } 31 }
32 32
@@ -34,7 +34,7 @@ const videoFilesDeleteWebTorrentValidator = [
34 } 34 }
35] 35]
36 36
37const videoFilesDeleteWebTorrentFileValidator = [ 37const videoFilesDeleteWebVideoFileValidator = [
38 isValidVideoIdParam('id'), 38 isValidVideoIdParam('id'),
39 39
40 param('videoFileId') 40 param('videoFileId')
@@ -52,14 +52,14 @@ const videoFilesDeleteWebTorrentFileValidator = [
52 if (!files.find(f => f.id === +req.params.videoFileId)) { 52 if (!files.find(f => f.id === +req.params.videoFileId)) {
53 return res.fail({ 53 return res.fail({
54 status: HttpStatusCode.NOT_FOUND_404, 54 status: HttpStatusCode.NOT_FOUND_404,
55 message: 'This video does not have this WebTorrent file id' 55 message: 'This video does not have this Web Video file id'
56 }) 56 })
57 } 57 }
58 58
59 if (files.length === 1 && !video.getHLSPlaylist()) { 59 if (files.length === 1 && !video.getHLSPlaylist()) {
60 return res.fail({ 60 return res.fail({
61 status: HttpStatusCode.BAD_REQUEST_400, 61 status: HttpStatusCode.BAD_REQUEST_400,
62 message: 'Cannot delete WebTorrent files since this video does not have HLS playlist' 62 message: 'Cannot delete Web Video files since this video does not have HLS playlist'
63 }) 63 })
64 } 64 }
65 65
@@ -87,10 +87,10 @@ const videoFilesDeleteHLSValidator = [
87 }) 87 })
88 } 88 }
89 89
90 if (!video.hasWebTorrentFiles()) { 90 if (!video.hasWebVideoFiles()) {
91 return res.fail({ 91 return res.fail({
92 status: HttpStatusCode.BAD_REQUEST_400, 92 status: HttpStatusCode.BAD_REQUEST_400,
93 message: 'Cannot delete HLS playlist since this video does not have WebTorrent files' 93 message: 'Cannot delete HLS playlist since this video does not have Web Video files'
94 }) 94 })
95 } 95 }
96 96
@@ -128,10 +128,10 @@ const videoFilesDeleteHLSFileValidator = [
128 } 128 }
129 129
130 // Last file to delete 130 // Last file to delete
131 if (hlsFiles.length === 1 && !video.hasWebTorrentFiles()) { 131 if (hlsFiles.length === 1 && !video.hasWebVideoFiles()) {
132 return res.fail({ 132 return res.fail({
133 status: HttpStatusCode.BAD_REQUEST_400, 133 status: HttpStatusCode.BAD_REQUEST_400,
134 message: 'Cannot delete last HLS playlist file since this video does not have WebTorrent files' 134 message: 'Cannot delete last HLS playlist file since this video does not have Web Video files'
135 }) 135 })
136 } 136 }
137 137
@@ -140,8 +140,8 @@ const videoFilesDeleteHLSFileValidator = [
140] 140]
141 141
142export { 142export {
143 videoFilesDeleteWebTorrentValidator, 143 videoFilesDeleteWebVideoValidator,
144 videoFilesDeleteWebTorrentFileValidator, 144 videoFilesDeleteWebVideoFileValidator,
145 145
146 videoFilesDeleteHLSValidator, 146 videoFilesDeleteHLSValidator,
147 videoFilesDeleteHLSFileValidator 147 videoFilesDeleteHLSFileValidator
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index b829e4eb4..b39d13a23 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -506,10 +506,14 @@ const commonVideosFiltersValidator = [
506 .optional() 506 .optional()
507 .customSanitizer(toBooleanOrNull) 507 .customSanitizer(toBooleanOrNull)
508 .custom(isBooleanValid).withMessage('Should have a valid hasHLSFiles boolean'), 508 .custom(isBooleanValid).withMessage('Should have a valid hasHLSFiles boolean'),
509 query('hasWebtorrentFiles') 509 query('hasWebtorrentFiles') // TODO: remove in v7
510 .optional() 510 .optional()
511 .customSanitizer(toBooleanOrNull) 511 .customSanitizer(toBooleanOrNull)
512 .custom(isBooleanValid).withMessage('Should have a valid hasWebtorrentFiles boolean'), 512 .custom(isBooleanValid).withMessage('Should have a valid hasWebtorrentFiles boolean'),
513 query('hasWebVideoFiles')
514 .optional()
515 .customSanitizer(toBooleanOrNull)
516 .custom(isBooleanValid).withMessage('Should have a valid hasWebVideoFiles boolean'),
513 query('skipCount') 517 query('skipCount')
514 .optional() 518 .optional()
515 .customSanitizer(toBooleanOrNull) 519 .customSanitizer(toBooleanOrNull)