aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-01-09 14:10:23 +0100
committerRigel Kent <sendmemail@rigelk.eu>2020-01-09 14:11:39 +0100
commit205ed5b7dcc4ac8b1bc9a02ff2201261c5075633 (patch)
treebbdc4cda7cf2814c59999153eefc87700a8b47ae
parentf44a284a3e863cac144d1675208a38422ac0fc8c (diff)
downloadPeerTube-205ed5b7dcc4ac8b1bc9a02ff2201261c5075633.tar.gz
PeerTube-205ed5b7dcc4ac8b1bc9a02ff2201261c5075633.tar.zst
PeerTube-205ed5b7dcc4ac8b1bc9a02ff2201261c5075633.zip
Add video caption upload documentation and improve error message
fixes #2038
-rw-r--r--server/middlewares/validators/videos/video-captions.ts8
-rw-r--r--support/doc/api/openapi.yaml2
2 files changed, 5 insertions, 5 deletions
diff --git a/server/middlewares/validators/videos/video-captions.ts b/server/middlewares/validators/videos/video-captions.ts
index 2fb1da5ce..7b0cd6f66 100644
--- a/server/middlewares/validators/videos/video-captions.ts
+++ b/server/middlewares/validators/videos/video-captions.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { areValidationErrors } from '../utils' 2import { areValidationErrors } from '../utils'
3import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' 3import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
4import { body, param } from 'express-validator' 4import { body, param } from 'express-validator'
5import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' 5import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants'
6import { UserRight } from '../../../../shared' 6import { UserRight } from '../../../../shared'
7import { logger } from '../../../helpers/logger' 7import { logger } from '../../../helpers/logger'
8import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions' 8import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions'
@@ -13,9 +13,9 @@ const addVideoCaptionValidator = [
13 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'), 13 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'),
14 param('captionLanguage').custom(isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'), 14 param('captionLanguage').custom(isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'),
15 body('captionfile') 15 body('captionfile')
16 .custom((value, { req }) => isVideoCaptionFile(req.files, 'captionfile')).withMessage( 16 .custom((_, { req }) => isVideoCaptionFile(req.files, 'captionfile')).withMessage(
17 'This caption file is not supported or too large. Please, make sure it is of the following type : ' 17 `This caption file is not supported or too large. Please, make sure it is under ${CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE} and one of the following mimetypes: `
18 + CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME.join(', ') 18 + Object.keys(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT).map(key => `${key} (${MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT[key]})`).join(', ')
19 ), 19 ),
20 20
21 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 21 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index a193bebab..9c56bb27a 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -1292,7 +1292,7 @@ paths:
1292 format: binary 1292 format: binary
1293 encoding: 1293 encoding:
1294 captionfile: 1294 captionfile:
1295 contentType: text/vtt, application/x-subrip 1295 contentType: text/vtt, application/x-subrip, text/plain
1296 responses: 1296 responses:
1297 '204': 1297 '204':
1298 $ref: '#/paths/~1users~1me/put/responses/204' 1298 $ref: '#/paths/~1users~1me/put/responses/204'