ActivityPub-federated video streaming platform using P2P directly in your web browser
Cleanup useless express validator messages
Chocobozzz396f6f0140b0
diff --git a/server/middlewares/validators/abuse.ts b/server/middlewares/validators/abuse.tsindex 22f66c8cff..e4aa1a8399 100644--- a/server/middlewares/validators/abuse.ts+++ b/server/middlewares/validators/abuse.ts@@ -22,41 +22,34 @@ import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdEconst abuseReportValidator = [body('account.id').optional()- .custom(isIdValid)- .withMessage('Should have a valid accountId'),+ .custom(isIdValid),body('video.id').optional().customSanitizer(toCompleteUUID)- .custom(isIdOrUUIDValid)- .withMessage('Should have a valid videoId'),+ .custom(isIdOrUUIDValid),body('video.startAt').optional().customSanitizer(toIntOrNull)- .custom(isAbuseTimestampValid)- .withMessage('Should have valid starting time value'),+ .custom(isAbuseTimestampValid),body('video.endAt').optional().customSanitizer(toIntOrNull).custom(isAbuseTimestampValid)- .withMessage('Should have valid ending time value').bail().custom(isAbuseTimestampCoherent).withMessage('Should have a startAt timestamp beginning before endAt'),body('comment.id').optional()- .custom(isIdValid)- .withMessage('Should have a valid commentId'),+ .custom(isIdValid),body('reason')- .custom(isAbuseReasonValid)- .withMessage('Should have a valid reason'),+ .custom(isAbuseReasonValid),body('predefinedReasons').optional()- .custom(areAbusePredefinedReasonsValid)- .withMessage('Should have a valid list of predefined reasons'),+ .custom(areAbusePredefinedReasonsValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking abuseReport parameters', { parameters: req.body })@@ -79,7 +72,8 @@ const abuseReportValidator = []const abuseGetValidator = [- param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'),+ param('id')+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking abuseGetValidator parameters', { parameters: req.body })@@ -92,14 +86,15 @@ const abuseGetValidator = []const abuseUpdateValidator = [- param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'),+ param('id')+ .custom(isIdValid),body('state').optional()- .custom(isAbuseStateValid).withMessage('Should have a valid abuse state'),+ .custom(isAbuseStateValid),body('moderationComment').optional()- .custom(isAbuseModerationCommentValid).withMessage('Should have a valid moderation comment'),+ .custom(isAbuseModerationCommentValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking abuseUpdateValidator parameters', { parameters: req.body })@@ -114,36 +109,34 @@ const abuseUpdateValidator = [const abuseListForAdminsValidator = [query('id').optional()- .custom(isIdValid).withMessage('Should have a valid id'),+ .custom(isIdValid),query('filter').optional()- .custom(isAbuseFilterValid)- .withMessage('Should have a valid filter'),+ .custom(isAbuseFilterValid),query('predefinedReason').optional()- .custom(isAbusePredefinedReasonValid)- .withMessage('Should have a valid predefinedReason'),+ .custom(isAbusePredefinedReasonValid),query('search').optional()- .custom(exists).withMessage('Should have a valid search'),+ .custom(exists),query('state').optional()- .custom(isAbuseStateValid).withMessage('Should have a valid abuse state'),+ .custom(isAbuseStateValid),query('videoIs').optional()- .custom(isAbuseVideoIsValid).withMessage('Should have a valid "video is" attribute'),+ .custom(isAbuseVideoIsValid),query('searchReporter').optional()- .custom(exists).withMessage('Should have a valid reporter search'),+ .custom(exists),query('searchReportee').optional()- .custom(exists).withMessage('Should have a valid reportee search'),+ .custom(exists),query('searchVideo').optional()- .custom(exists).withMessage('Should have a valid video search'),+ .custom(exists),query('searchVideoChannel').optional()- .custom(exists).withMessage('Should have a valid video channel search'),+ .custom(exists),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking abuseListForAdminsValidator parameters', { parameters: req.body })@@ -157,15 +150,15 @@ const abuseListForAdminsValidator = [const abuseListForUserValidator = [query('id').optional()- .custom(isIdValid).withMessage('Should have a valid id'),+ .custom(isIdValid),query('search').optional()- .custom(exists).withMessage('Should have a valid search'),+ .custom(exists),query('state').optional()- .custom(isAbuseStateValid).withMessage('Should have a valid abuse state'),+ .custom(isAbuseStateValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking abuseListForUserValidator parameters', { parameters: req.body })@@ -177,7 +170,8 @@ const abuseListForUserValidator = []const getAbuseValidator = [- param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'),+ param('id')+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking getAbuseValidator parameters', { parameters: req.body })@@ -216,7 +210,8 @@ const checkAbuseValidForMessagesValidator = []const addAbuseMessageValidator = [- body('message').custom(isAbuseMessageValid).not().isEmpty().withMessage('Should have a valid abuse message'),+ body('message')+ .custom(isAbuseMessageValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking addAbuseMessageValidator parameters', { parameters: req.body })@@ -228,7 +223,8 @@ const addAbuseMessageValidator = []const deleteAbuseMessageValidator = [- param('messageId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid message id'),+ param('messageId')+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking deleteAbuseMessageValidator parameters', { parameters: req.body })diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.tsindex e529c831d5..a7534ced52 100644--- a/server/middlewares/validators/account.ts+++ b/server/middlewares/validators/account.ts@@ -5,7 +5,8 @@ import { logger } from '../../helpers/logger'import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared'const localAccountValidator = [- param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),+ param('name')+ .custom(isAccountNameValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking localAccountValidator parameters', { parameters: req.params })@@ -18,7 +19,8 @@ const localAccountValidator = []const accountNameWithHostGetValidator = [- param('accountName').exists().withMessage('Should have an account name with host'),+ param('accountName')+ .exists(),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params })diff --git a/server/middlewares/validators/activitypub/pagination.ts b/server/middlewares/validators/activitypub/pagination.tsindex c542d41731..69c4febaf0 100644--- a/server/middlewares/validators/activitypub/pagination.ts+++ b/server/middlewares/validators/activitypub/pagination.ts@@ -7,7 +7,7 @@ import { areValidationErrors } from '../shared'const apPaginationValidator = [query('page').optional()- .isInt({ min: 1 }).withMessage('Should have a valid page number'),+ .isInt({ min: 1 }),query('size').optional().isInt({ min: 0, max: PAGINATION.OUTBOX.COUNT.MAX }).withMessage(`Should have a valid page size (max: ${PAGINATION.OUTBOX.COUNT.MAX})`),diff --git a/server/middlewares/validators/activitypub/signature.ts b/server/middlewares/validators/activitypub/signature.tsindex 642bcefe0d..8c133ecef2 100644--- a/server/middlewares/validators/activitypub/signature.ts+++ b/server/middlewares/validators/activitypub/signature.ts@@ -12,16 +12,16 @@ import { areValidationErrors } from '../shared'const signatureValidator = [body('signature.type').optional()- .custom(isSignatureTypeValid).withMessage('Should have a valid signature type'),+ .custom(isSignatureTypeValid),body('signature.created').optional().custom(isDateValid).withMessage('Should have a signature created date that conforms to ISO 8601'),body('signature.creator').optional()- .custom(isSignatureCreatorValid).withMessage('Should have a valid signature creator'),+ .custom(isSignatureCreatorValid),body('signature.signatureValue').optional()- .custom(isSignatureValueValid).withMessage('Should have a valid signature value'),+ .custom(isSignatureValueValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking Linked Data Signature parameter', { parameters: { signature: req.body.signature } })diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.tsindex 12980ced4d..3de614522d 100644--- a/server/middlewares/validators/blocklist.ts+++ b/server/middlewares/validators/blocklist.ts@@ -13,7 +13,8 @@ import { ServerBlocklistModel } from '../../models/server/server-blocklist'import { areValidationErrors, doesAccountNameWithHostExist } from './shared'const blockAccountValidator = [- body('accountName').exists().withMessage('Should have an account name with host'),+ body('accountName')+ .exists(),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body })@@ -37,7 +38,8 @@ const blockAccountValidator = []const unblockAccountByAccountValidator = [- param('accountName').exists().withMessage('Should have an account name with host'),+ param('accountName')+ .exists(),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params })@@ -54,7 +56,8 @@ const unblockAccountByAccountValidator = []const unblockAccountByServerValidator = [- param('accountName').exists().withMessage('Should have an account name with host'),+ param('accountName')+ .exists(),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params })@@ -71,7 +74,8 @@ const unblockAccountByServerValidator = []const blockServerValidator = [- body('host').custom(isHostValid).withMessage('Should have a valid host'),+ body('host')+ .custom(isHostValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking serverGetValidator parameters', { parameters: req.body })@@ -96,7 +100,8 @@ const blockServerValidator = []const unblockServerByAccountValidator = [- param('host').custom(isHostValid).withMessage('Should have an account name with host'),+ param('host')+ .custom(isHostValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking unblockServerByAccountValidator parameters', { parameters: req.params })@@ -111,7 +116,8 @@ const unblockServerByAccountValidator = []const unblockServerByServerValidator = [- param('host').custom(isHostValid).withMessage('Should have an account name with host'),+ param('host')+ .custom(isHostValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking unblockServerByServerValidator parameters', { parameters: req.params })diff --git a/server/middlewares/validators/bulk.ts b/server/middlewares/validators/bulk.tsindex 1cfc7481ee..5bc15e0761 100644--- a/server/middlewares/validators/bulk.ts+++ b/server/middlewares/validators/bulk.ts@@ -7,9 +7,10 @@ import { logger } from '../../helpers/logger'import { areValidationErrors, doesAccountNameWithHostExist } from './shared'const bulkRemoveCommentsOfValidator = [- body('accountName').exists().withMessage('Should have an account name with host'),+ body('accountName')+ .exists(),body('scope')- .custom(isBulkRemoveCommentsOfScopeValid).withMessage('Should have a valid scope'),+ .custom(isBulkRemoveCommentsOfScopeValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking bulkRemoveCommentsOfValidator parameters', { parameters: req.body })diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.tsindex f60103f480..c89f3087e3 100644--- a/server/middlewares/validators/config.ts+++ b/server/middlewares/validators/config.ts@@ -11,100 +11,98 @@ import { areValidationErrors } from './shared'import { HttpStatusCode } from '@shared/models/http/http-error-codes'const customConfigUpdateValidator = [- body('instance.name').exists().withMessage('Should have a valid instance name'),- body('instance.shortDescription').exists().withMessage('Should have a valid instance short description'),- body('instance.description').exists().withMessage('Should have a valid instance description'),- body('instance.terms').exists().withMessage('Should have a valid instance terms'),- body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid).withMessage('Should have a valid NSFW policy'),- body('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'),- body('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'),- body('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'),-- body('services.twitter.username').exists().withMessage('Should have a valid twitter username'),- body('services.twitter.whitelisted').isBoolean().withMessage('Should have a valid twitter whitelisted boolean'),-- body('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'),- body('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'),- body('cache.torrents.size').isInt().withMessage('Should have a valid torrents cache size'),-- body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'),- body('signup.limit').isInt().withMessage('Should have a valid signup limit'),- body('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'),- body('signup.minimumAge').isInt().withMessage('Should have a valid minimum age required'),-- body('admin.email').isEmail().withMessage('Should have a valid administrator email'),- body('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'),-- body('user.videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid video quota'),- body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily video quota'),-- body('videoChannels.maxPerUser').isInt().withMessage('Should have a valid maximum amount of video channels per user'),-- body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'),- body('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'),- body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'),- body('transcoding.concurrency').isInt({ min: 1 }).withMessage('Should have a valid transcoding concurrency number'),- body('transcoding.resolutions.0p').isBoolean().withMessage('Should have a valid transcoding 0p resolution enabled boolean'),- body('transcoding.resolutions.144p').isBoolean().withMessage('Should have a valid transcoding 144p resolution enabled boolean'),- body('transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'),- body('transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'),- body('transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'),- body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'),- body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'),- body('transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'),- body('transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'),-- body('transcoding.alwaysTranscodeOriginalResolution').isBoolean()- .withMessage('Should have a valid always transcode original resolution boolean'),-- body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'),- body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid hls transcoding enabled boolean'),-- body('videoStudio.enabled').isBoolean().withMessage('Should have a valid video studio enabled boolean'),-- body('import.videos.concurrency').isInt({ min: 0 }).withMessage('Should have a valid import concurrency number'),- body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'),- body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'),-- body('import.videoChannelSynchronization.enabled').isBoolean().withMessage('Should have a valid synchronization enabled boolean'),-- body('trending.videos.algorithms.default').exists().withMessage('Should have a valid default trending algorithm'),- body('trending.videos.algorithms.enabled').exists().withMessage('Should have a valid array of enabled trending algorithms'),-- body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'),- body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'),-- body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'),-- body('broadcastMessage.enabled').isBoolean().withMessage('Should have a valid broadcast message enabled boolean'),- body('broadcastMessage.message').exists().withMessage('Should have a valid broadcast message'),- body('broadcastMessage.level').exists().withMessage('Should have a valid broadcast level'),- body('broadcastMessage.dismissable').isBoolean().withMessage('Should have a valid broadcast dismissable boolean'),-- body('live.enabled').isBoolean().withMessage('Should have a valid live enabled boolean'),- body('live.allowReplay').isBoolean().withMessage('Should have a valid live allow replay boolean'),- body('live.maxDuration').isInt().withMessage('Should have a valid live max duration'),- body('live.maxInstanceLives').custom(isIntOrNull).withMessage('Should have a valid max instance lives'),- body('live.maxUserLives').custom(isIntOrNull).withMessage('Should have a valid max user lives'),- body('live.transcoding.enabled').isBoolean().withMessage('Should have a valid live transcoding enabled boolean'),- body('live.transcoding.threads').isInt().withMessage('Should have a valid live transcoding threads'),- body('live.transcoding.resolutions.144p').isBoolean().withMessage('Should have a valid transcoding 144p resolution enabled boolean'),- body('live.transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'),- body('live.transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'),- body('live.transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'),- body('live.transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'),- body('live.transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'),- body('live.transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'),- body('live.transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'),- body('live.transcoding.alwaysTranscodeOriginalResolution').isBoolean()- .withMessage('Should have a valid always transcode live original resolution boolean'),-- body('search.remoteUri.users').isBoolean().withMessage('Should have a remote URI search for users boolean'),- body('search.remoteUri.anonymous').isBoolean().withMessage('Should have a valid remote URI search for anonymous boolean'),- body('search.searchIndex.enabled').isBoolean().withMessage('Should have a valid search index enabled boolean'),- body('search.searchIndex.url').exists().withMessage('Should have a valid search index URL'),- body('search.searchIndex.disableLocalSearch').isBoolean().withMessage('Should have a valid search index disable local search boolean'),- body('search.searchIndex.isDefaultSearch').isBoolean().withMessage('Should have a valid search index default enabled boolean'),+ body('instance.name').exists(),+ body('instance.shortDescription').exists(),+ body('instance.description').exists(),+ body('instance.terms').exists(),+ body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid),+ body('instance.defaultClientRoute').exists(),+ body('instance.customizations.css').exists(),+ body('instance.customizations.javascript').exists(),++ body('services.twitter.username').exists(),+ body('services.twitter.whitelisted').isBoolean(),++ body('cache.previews.size').isInt(),+ body('cache.captions.size').isInt(),+ body('cache.torrents.size').isInt(),++ body('signup.enabled').isBoolean(),+ body('signup.limit').isInt(),+ body('signup.requiresEmailVerification').isBoolean(),+ body('signup.minimumAge').isInt(),++ body('admin.email').isEmail(),+ body('contactForm.enabled').isBoolean(),++ body('user.videoQuota').custom(isUserVideoQuotaValid),+ body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid),++ body('videoChannels.maxPerUser').isInt(),++ body('transcoding.enabled').isBoolean(),+ body('transcoding.allowAdditionalExtensions').isBoolean(),+ body('transcoding.threads').isInt(),+ body('transcoding.concurrency').isInt({ min: 1 }),+ body('transcoding.resolutions.0p').isBoolean(),+ body('transcoding.resolutions.144p').isBoolean(),+ body('transcoding.resolutions.240p').isBoolean(),+ body('transcoding.resolutions.360p').isBoolean(),+ body('transcoding.resolutions.480p').isBoolean(),+ body('transcoding.resolutions.720p').isBoolean(),+ body('transcoding.resolutions.1080p').isBoolean(),+ body('transcoding.resolutions.1440p').isBoolean(),+ body('transcoding.resolutions.2160p').isBoolean(),++ body('transcoding.alwaysTranscodeOriginalResolution').isBoolean(),++ body('transcoding.webtorrent.enabled').isBoolean(),+ body('transcoding.hls.enabled').isBoolean(),++ body('videoStudio.enabled').isBoolean(),++ body('import.videos.concurrency').isInt({ min: 0 }),+ body('import.videos.http.enabled').isBoolean(),+ body('import.videos.torrent.enabled').isBoolean(),++ body('import.videoChannelSynchronization.enabled').isBoolean(),++ body('trending.videos.algorithms.default').exists(),+ body('trending.videos.algorithms.enabled').exists(),++ body('followers.instance.enabled').isBoolean(),+ body('followers.instance.manualApproval').isBoolean(),++ body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)),++ body('broadcastMessage.enabled').isBoolean(),+ body('broadcastMessage.message').exists(),+ body('broadcastMessage.level').exists(),+ body('broadcastMessage.dismissable').isBoolean(),++ body('live.enabled').isBoolean(),+ body('live.allowReplay').isBoolean(),+ body('live.maxDuration').isInt(),+ body('live.maxInstanceLives').custom(isIntOrNull),+ body('live.maxUserLives').custom(isIntOrNull),+ body('live.transcoding.enabled').isBoolean(),+ body('live.transcoding.threads').isInt(),+ body('live.transcoding.resolutions.144p').isBoolean(),+ body('live.transcoding.resolutions.240p').isBoolean(),+ body('live.transcoding.resolutions.360p').isBoolean(),+ body('live.transcoding.resolutions.480p').isBoolean(),+ body('live.transcoding.resolutions.720p').isBoolean(),+ body('live.transcoding.resolutions.1080p').isBoolean(),+ body('live.transcoding.resolutions.1440p').isBoolean(),+ body('live.transcoding.resolutions.2160p').isBoolean(),+ body('live.transcoding.alwaysTranscodeOriginalResolution').isBoolean(),++ body('search.remoteUri.users').isBoolean(),+ body('search.remoteUri.anonymous').isBoolean(),+ body('search.searchIndex.enabled').isBoolean(),+ body('search.searchIndex.url').exists(),+ body('search.searchIndex.disableLocalSearch').isBoolean(),+ body('search.searchIndex.isDefaultSearch').isBoolean(),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body })diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.tsindex 04b4e00c9c..900c1d3835 100644--- a/server/middlewares/validators/feeds.ts+++ b/server/middlewares/validators/feeds.ts@@ -16,8 +16,20 @@ import {} from './shared'const feedsFormatValidator = [- param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),- query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)')+ param('format')+ .optional()+ .custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),+ query('format')+ .optional()+ .custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),++ (req: express.Request, res: express.Response, next: express.NextFunction) => {+ logger.debug('Checking feeds format parameters', { parameters: req.query })++ if (areValidationErrors(req, res)) return++ return next()+ }]function setFeedFormatContentType (req: express.Request, res: express.Response, next: express.NextFunction) {@@ -49,16 +61,14 @@ function setFeedFormatContentType (req: express.Request, res: express.Response,const videoFeedsValidator = [query('accountId').optional()- .custom(isIdValid)- .withMessage('Should have a valid account id'),+ .custom(isIdValid),query('accountName').optional(),query('videoChannelId').optional()- .custom(isIdValid)- .withMessage('Should have a valid channel id'),+ .custom(isIdValid),query('videoChannelName').optional(),@@ -79,12 +89,10 @@ const videoFeedsValidator = [const videoSubscriptionFeedsValidator = [query('accountId')- .custom(isIdValid)- .withMessage('Should have a valid account id'),+ .custom(isIdValid),query('token')- .custom(exists)- .withMessage('Should have a token'),+ .custom(exists),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking subscription feeds parameters', { parameters: req.query })@@ -100,8 +108,8 @@ const videoSubscriptionFeedsValidator = [const videoCommentsFeedsValidator = [query('videoId')- .customSanitizer(toCompleteUUID).optional()+ .customSanitizer(toCompleteUUID).custom(isIdOrUUIDValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.tsindex 023dba5b53..639c60c030 100644--- a/server/middlewares/validators/follows.ts+++ b/server/middlewares/validators/follows.ts@@ -19,10 +19,10 @@ import { areValidationErrors } from './shared'const listFollowsValidator = [query('state').optional()- .custom(isFollowStateValid).withMessage('Should have a valid follow state'),+ .custom(isFollowStateValid),query('actorType').optional()- .custom(isActorTypeValid).withMessage('Should have a valid actor type'),+ .custom(isActorTypeValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return@@ -70,8 +70,7 @@ const followValidator = [const removeFollowingValidator = [param('hostOrHandle')- .custom(value => isHostValid(value) || isRemoteHandleValid(value))- .withMessage('Should have a valid host/handle'),+ .custom(value => isHostValid(value) || isRemoteHandleValid(value)),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking unfollowing parameters', { parameters: req.params })@@ -100,7 +99,8 @@ const removeFollowingValidator = []const getFollowerValidator = [- param('nameWithHost').custom(isValidActorHandle).withMessage('Should have a valid nameWithHost'),+ param('nameWithHost')+ .custom(isValidActorHandle),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking get follower parameters', { parameters: req.params })diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.tsindex 4de90548b0..971c2060c8 100644--- a/server/middlewares/validators/jobs.ts+++ b/server/middlewares/validators/jobs.ts@@ -8,12 +8,12 @@ const lTags = loggerTagsFactory('validators', 'jobs')const listJobsValidator = [param('state')- .optional()- .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'),+ .optional()+ .custom(isValidJobState),query('jobType').optional()- .custom(isValidJobType).withMessage('Should have a valid job state'),+ .custom(isValidJobType),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking listJobsValidator parameters.', { parameters: req.params, ...lTags() })diff --git a/server/middlewares/validators/logs.ts b/server/middlewares/validators/logs.tsindex 324ba6915e..ce36dc40b4 100644--- a/server/middlewares/validators/logs.ts+++ b/server/middlewares/validators/logs.ts@@ -18,25 +18,25 @@ import { areValidationErrors } from './shared'const createClientLogValidator = [body('message')- .custom(isValidClientLogMessage).withMessage('Should have a valid log message'),+ .custom(isValidClientLogMessage),body('url')- .custom(isUrlValid).withMessage('Should have a valid log url'),+ .custom(isUrlValid),body('level')- .custom(isValidClientLogLevel).withMessage('Should have a valid log message'),+ .custom(isValidClientLogLevel),body('stackTrace').optional()- .custom(isValidClientLogStackTrace).withMessage('Should have a valid log stack trace'),+ .custom(isValidClientLogStackTrace),body('meta').optional()- .custom(isValidClientLogMeta).withMessage('Should have a valid log meta'),+ .custom(isValidClientLogMeta),body('userAgent').optional()- .custom(isValidClientLogUserAgent).withMessage('Should have a valid log user agent'),+ .custom(isValidClientLogUserAgent),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking createClientLogValidator parameters.', { parameters: req.query })@@ -56,7 +56,7 @@ const getLogsValidator = [.custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),query('level').optional()- .custom(isValidLogLevel).withMessage('Should have a valid level'),+ .custom(isValidLogLevel),query('tagsOneOf').optional().customSanitizer(toArray)diff --git a/server/middlewares/validators/metrics.ts b/server/middlewares/validators/metrics.tsindex b1dbec603c..cd6f872daa 100644--- a/server/middlewares/validators/metrics.ts+++ b/server/middlewares/validators/metrics.ts@@ -9,30 +9,29 @@ import { areValidationErrors, doesVideoExist } from './shared'const addPlaybackMetricValidator = [body('resolution')- .isInt({ min: 0 }).withMessage('Invalid resolution'),+ .isInt({ min: 0 }),body('fps').optional()- .isInt({ min: 0 }).withMessage('Invalid fps'),+ .isInt({ min: 0 }),body('playerMode')- .custom(isValidPlayerMode).withMessage('Invalid playerMode'),+ .custom(isValidPlayerMode),body('resolutionChanges')- .isInt({ min: 0 }).withMessage('Invalid resolutionChanges'),+ .isInt({ min: 0 }),body('errors')- .isInt({ min: 0 }).withMessage('Invalid errors'),+ .isInt({ min: 0 }),body('downloadedBytesP2P')- .isInt({ min: 0 }).withMessage('Invalid downloadedBytesP2P'),+ .isInt({ min: 0 }),body('downloadedBytesHTTP')- .isInt({ min: 0 }).withMessage('Invalid downloadedBytesHTTP'),+ .isInt({ min: 0 }),body('uploadedBytesP2P')- .isInt({ min: 0 }).withMessage('Invalid uploadedBytesP2P'),+ .isInt({ min: 0 }),body('videoId').customSanitizer(toCompleteUUID)- .optional().custom(isIdOrUUIDValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.tsindex 8e7b44a86a..fa90dd05c9 100644--- a/server/middlewares/validators/oembed.ts+++ b/server/middlewares/validators/oembed.ts@@ -39,10 +39,17 @@ if (isTestOrDevInstance()) {}const oembedValidator = [- query('url').isURL(isURLOptions).withMessage('Should have a valid url'),- query('maxwidth').optional().isInt().withMessage('Should have a valid max width'),- query('maxheight').optional().isInt().withMessage('Should have a valid max height'),- query('format').optional().isIn([ 'xml', 'json' ]).withMessage('Should have a valid format'),+ query('url')+ .isURL(isURLOptions),+ query('maxwidth')+ .optional()+ .isInt(),+ query('maxheight')+ .optional()+ .isInt(),+ query('format')+ .optional()+ .isIn([ 'xml', 'json' ]),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking oembed parameters', { parameters: req.query })diff --git a/server/middlewares/validators/pagination.ts b/server/middlewares/validators/pagination.tsindex 8e4922b9d4..ce371d6c11 100644--- a/server/middlewares/validators/pagination.ts+++ b/server/middlewares/validators/pagination.ts@@ -10,7 +10,7 @@ function paginationValidatorBuilder (tags: string[] = []) {return [query('start').optional()- .isInt({ min: 0 }).withMessage('Should have a number start'),+ .isInt({ min: 0 }),query('count').optional().isInt({ min: 0, max: PAGINATION.GLOBAL.COUNT.MAX }).withMessage(`Should have a number count (max: ${PAGINATION.GLOBAL.COUNT.MAX})`),diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.tsindex c1e9ebefbb..dc80469c31 100644--- a/server/middlewares/validators/plugins.ts+++ b/server/middlewares/validators/plugins.ts@@ -13,12 +13,14 @@ import { areValidationErrors } from './shared'const getPluginValidator = (pluginType: PluginType, withVersion = true) => {const validators: (ValidationChain | express.Handler)[] = [- param('pluginName').custom(isPluginNameValid).withMessage('Should have a valid plugin name')+ param('pluginName')+ .custom(isPluginNameValid)]if (withVersion) {validators.push(- param('pluginVersion').custom(isPluginVersionValid).withMessage('Should have a valid plugin version')+ param('pluginVersion')+ .custom(isPluginVersionValid))}@@ -52,7 +54,8 @@ const getPluginValidator = (pluginType: PluginType, withVersion = true) => {}const getExternalAuthValidator = [- param('authName').custom(exists).withMessage('Should have a valid auth name'),+ param('authName')+ .custom(exists),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking getExternalAuthValidator parameters', { parameters: req.params })@@ -82,7 +85,8 @@ const getExternalAuthValidator = []const pluginStaticDirectoryValidator = [- param('staticEndpoint').custom(isSafePath).withMessage('Should have a valid static endpoint'),+ param('staticEndpoint')+ .custom(isSafePath),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking pluginStaticDirectoryValidator parameters', { parameters: req.params })@@ -97,11 +101,11 @@ const listPluginsValidator = [query('pluginType').optional().customSanitizer(toIntOrNull)- .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),+ .custom(isPluginTypeValid),query('uninstalled').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid uninstalled attribute'),+ .custom(isBooleanValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking listPluginsValidator parameters', { parameters: req.query })@@ -115,13 +119,13 @@ const listPluginsValidator = [const installOrUpdatePluginValidator = [body('npmName').optional()- .custom(isNpmPluginNameValid).withMessage('Should have a valid npm name'),+ .custom(isNpmPluginNameValid),body('pluginVersion').optional()- .custom(isPluginVersionValid).withMessage('Should have a valid plugin version'),+ .custom(isPluginVersionValid),body('path').optional()- .custom(isSafePath).withMessage('Should have a valid safe path'),+ .custom(isSafePath),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking installOrUpdatePluginValidator parameters', { parameters: req.body })@@ -141,7 +145,8 @@ const installOrUpdatePluginValidator = []const uninstallPluginValidator = [- body('npmName').custom(isNpmPluginNameValid).withMessage('Should have a valid npm name'),+ body('npmName')+ .custom(isNpmPluginNameValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking uninstallPluginValidator parameters', { parameters: req.body })@@ -153,7 +158,8 @@ const uninstallPluginValidator = []const existingPluginValidator = [- param('npmName').custom(isNpmPluginNameValid).withMessage('Should have a valid plugin name'),+ param('npmName')+ .custom(isNpmPluginNameValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking enabledPluginValidator parameters', { parameters: req.params })@@ -174,7 +180,8 @@ const existingPluginValidator = []const updatePluginSettingsValidator = [- body('settings').exists().withMessage('Should have settings'),+ body('settings')+ .exists(),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking enabledPluginValidator parameters', { parameters: req.body })@@ -188,14 +195,14 @@ const updatePluginSettingsValidator = [const listAvailablePluginsValidator = [query('search').optional()- .exists().withMessage('Should have a valid search'),+ .exists(),query('pluginType').optional().customSanitizer(toIntOrNull)- .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),+ .custom(isPluginTypeValid),query('currentPeerTubeEngine').optional()- .custom(isPluginVersionValid).withMessage('Should have a valid current peertube engine'),+ .custom(isPluginVersionValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking enabledPluginValidator parameters', { parameters: req.query })diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.tsindex d31b216f59..a74772bd19 100644--- a/server/middlewares/validators/redundancy.ts+++ b/server/middlewares/validators/redundancy.ts@@ -22,11 +22,11 @@ const videoFileRedundancyGetValidator = [param('resolution').customSanitizer(toIntOrNull)- .custom(exists).withMessage('Should have a valid resolution'),+ .custom(exists),param('fps').optional().customSanitizer(toIntOrNull)- .custom(exists).withMessage('Should have a valid fps'),+ .custom(exists),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoFileRedundancyGetValidator parameters', { parameters: req.params })@@ -69,7 +69,7 @@ const videoPlaylistRedundancyGetValidator = [param('streamingPlaylistType').customSanitizer(toIntOrNull)- .custom(exists).withMessage('Should have a valid streaming playlist type'),+ .custom(exists),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params })@@ -104,10 +104,12 @@ const videoPlaylistRedundancyGetValidator = []const updateServerRedundancyValidator = [- param('host').custom(isHostValid).withMessage('Should have a valid host'),+ param('host')+ .custom(isHostValid),+body('redundancyAllowed').customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed attribute'),+ .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed boolean'),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking updateServerRedundancy parameters', { parameters: req.params })@@ -130,7 +132,7 @@ const updateServerRedundancyValidator = [const listVideoRedundanciesValidator = [query('target')- .custom(isVideoRedundancyTarget).withMessage('Should have a valid video redundancies target'),+ .custom(isVideoRedundancyTarget),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking listVideoRedundanciesValidator parameters', { parameters: req.query })@@ -144,8 +146,7 @@ const listVideoRedundanciesValidator = [const addVideoRedundancyValidator = [body('videoId').customSanitizer(toCompleteUUID)- .custom(isIdOrUUIDValid)- .withMessage('Should have a valid video id'),+ .custom(isIdOrUUIDValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking addVideoRedundancyValidator parameters', { parameters: req.query })@@ -176,8 +177,7 @@ const addVideoRedundancyValidator = [const removeVideoRedundancyValidator = [param('redundancyId')- .custom(isIdValid)- .withMessage('Should have a valid redundancy id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking removeVideoRedundancyValidator parameters', { parameters: req.query })diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.tsindex e6ec8642ad..827132468f 100644--- a/server/middlewares/validators/search.ts+++ b/server/middlewares/validators/search.ts@@ -7,11 +7,13 @@ import { logger } from '../../helpers/logger'import { areValidationErrors } from './shared'const videosSearchValidator = [- query('search').optional().not().isEmpty().withMessage('Should have a valid search'),+ query('search')+ .optional()+ .not().isEmpty(),query('host').optional()- .custom(isHostValid).withMessage('Should have a valid host'),+ .custom(isHostValid),query('startDate').optional()@@ -29,18 +31,20 @@ const videosSearchValidator = [query('durationMin').optional()- .isInt().withMessage('Should have a valid min duration'),+ .isInt(),query('durationMax').optional()- .isInt().withMessage('Should have a valid max duration'),+ .isInt(),query('uuids').optional().toArray().customSanitizer(toCompleteUUIDs)- .custom(areUUIDsValid).withMessage('Should have valid uuids'),+ .custom(areUUIDsValid).withMessage('Should have valid array of uuid'),- query('searchTarget').optional().custom(isSearchTargetValid).withMessage('Should have a valid search target'),+ query('searchTarget')+ .optional()+ .custom(isSearchTargetValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videos search query', { parameters: req.query })@@ -54,20 +58,20 @@ const videosSearchValidator = [const videoChannelsListSearchValidator = [query('search').optional()- .not().isEmpty().withMessage('Should have a valid search'),+ .not().isEmpty(),query('host').optional()- .custom(isHostValid).withMessage('Should have a valid host'),+ .custom(isHostValid),query('searchTarget').optional()- .custom(isSearchTargetValid).withMessage('Should have a valid search target'),+ .custom(isSearchTargetValid),query('handles').optional().toArray()- .custom(isNotEmptyStringArray).withMessage('Should have valid handles'),+ .custom(isNotEmptyStringArray).withMessage('Should have valid array of handles'),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking video channels search query', { parameters: req.query })@@ -81,21 +85,21 @@ const videoChannelsListSearchValidator = [const videoPlaylistsListSearchValidator = [query('search').optional()- .not().isEmpty().withMessage('Should have a valid search'),+ .not().isEmpty(),query('host').optional()- .custom(isHostValid).withMessage('Should have a valid host'),+ .custom(isHostValid),query('searchTarget').optional()- .custom(isSearchTargetValid).withMessage('Should have a valid search target'),+ .custom(isSearchTargetValid),query('uuids').optional().toArray().customSanitizer(toCompleteUUIDs)- .custom(areUUIDsValid).withMessage('Should have valid uuids'),+ .custom(areUUIDsValid).withMessage('Should have valid array of uuid'),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking video playlists search query', { parameters: req.query })diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.tsindex 10bbefe388..f6177f600b 100644--- a/server/middlewares/validators/server.ts+++ b/server/middlewares/validators/server.ts@@ -33,11 +33,11 @@ const serverGetValidator = [const contactAdministratorValidator = [body('fromName')- .custom(isUserDisplayNameValid).withMessage('Should have a valid name'),+ .custom(isUserDisplayNameValid),body('fromEmail')- .isEmail().withMessage('Should have a valid email'),+ .isEmail(),body('body')- .custom(isValidContactBody).withMessage('Should have a valid body'),+ .custom(isValidContactBody),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking contactAdministratorValidator parameters', { parameters: req.body })diff --git a/server/middlewares/validators/shared/utils.ts b/server/middlewares/validators/shared/utils.tsindex 410de4d80a..77b64bc7ab 100644--- a/server/middlewares/validators/shared/utils.ts+++ b/server/middlewares/validators/shared/utils.ts@@ -26,13 +26,13 @@ function areValidationErrors (req: express.Request, res: express.Response) {function isValidVideoIdParam (paramName: string) {return param(paramName).customSanitizer(toCompleteUUID)- .custom(isIdOrUUIDValid).withMessage('Should have a valid video id')+ .custom(isIdOrUUIDValid).withMessage('Should have a valid video id (id, short UUID or UUID)')}function isValidPlaylistIdParam (paramName: string) {return param(paramName).customSanitizer(toCompleteUUID)- .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id')+ .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id (id, short UUID or UUID)')}// ---------------------------------------------------------------------------diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.tsindex 0354e3fc6c..269f1be531 100644--- a/server/middlewares/validators/sort.ts+++ b/server/middlewares/validators/sort.ts@@ -10,7 +10,9 @@ function checkSortFactory (columns: string[], tags: string[] = []) {function checkSort (sortableColumns: string[], tags: string[] = []) {return [- query('sort').optional().isIn(sortableColumns).withMessage('Should have correct sortable column'),+ query('sort')+ .optional()+ .isIn(sortableColumns),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking sort parameters', { parameters: req.query, tags })diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.tsindex 7b9fee8588..f6a8c2d923 100644--- a/server/middlewares/validators/themes.ts+++ b/server/middlewares/validators/themes.ts@@ -8,9 +8,12 @@ import { PluginManager } from '../../lib/plugins/plugin-manager'import { areValidationErrors } from './shared'const serveThemeCSSValidator = [- param('themeName').custom(isPluginNameValid).withMessage('Should have a valid theme name'),- param('themeVersion').custom(isPluginVersionValid).withMessage('Should have a valid theme version'),- param('staticEndpoint').custom(isSafePath).withMessage('Should have a valid static endpoint'),+ param('themeName')+ .custom(isPluginNameValid),+ param('themeVersion')+ .custom(isPluginVersionValid),+ param('staticEndpoint')+ .custom(isSafePath),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking serveThemeCSS parameters', { parameters: req.params })diff --git a/server/middlewares/validators/user-history.ts b/server/middlewares/validators/user-history.tsindex 541910be55..23a00888ce 100644--- a/server/middlewares/validators/user-history.ts+++ b/server/middlewares/validators/user-history.ts@@ -7,7 +7,7 @@ import { areValidationErrors } from './shared'const userHistoryListValidator = [query('search').optional()- .custom(exists).withMessage('Should have a valid search'),+ .custom(exists),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query })@@ -34,7 +34,7 @@ const userHistoryRemoveAllValidator = [const userHistoryRemoveElementValidator = [param('videoId')- .custom(isIdValid).withMessage('Should have a valid video id'),+ .custom(isIdValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking userHistoryRemoveElementValidator parameters', { parameters: req.params })diff --git a/server/middlewares/validators/user-notifications.ts b/server/middlewares/validators/user-notifications.tsindex 4a7577d32e..f46303ab84 100644--- a/server/middlewares/validators/user-notifications.ts+++ b/server/middlewares/validators/user-notifications.ts@@ -22,29 +22,29 @@ const listUserNotificationsValidator = [const updateNotificationSettingsValidator = [body('newVideoFromSubscription')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new video from subscription notification setting'),+ .custom(isUserNotificationSettingValid),body('newCommentOnMyVideo')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new comment on my video notification setting'),+ .custom(isUserNotificationSettingValid),body('abuseAsModerator')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid abuse as moderator notification setting'),+ .custom(isUserNotificationSettingValid),body('videoAutoBlacklistAsModerator')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid video auto blacklist notification setting'),+ .custom(isUserNotificationSettingValid),body('blacklistOnMyVideo')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new blacklist on my video notification setting'),+ .custom(isUserNotificationSettingValid),body('myVideoImportFinished')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid video import finished video notification setting'),+ .custom(isUserNotificationSettingValid),body('myVideoPublished')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid video published notification setting'),+ .custom(isUserNotificationSettingValid),body('commentMention')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid comment mention notification setting'),+ .custom(isUserNotificationSettingValid),body('newFollow')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new follow notification setting'),+ .custom(isUserNotificationSettingValid),body('newUserRegistration')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new user registration notification setting'),+ .custom(isUserNotificationSettingValid),body('newInstanceFollower')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new instance follower notification setting'),+ .custom(isUserNotificationSettingValid),body('autoInstanceFollowing')- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new instance following notification setting'),+ .custom(isUserNotificationSettingValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking updateNotificationSettingsValidator parameters', { parameters: req.body })@@ -58,7 +58,7 @@ const updateNotificationSettingsValidator = [const markAsReadUserNotificationsValidator = [body('ids').optional()- .custom(isNotEmptyIntArray).withMessage('Should have a valid notification ids to mark as read'),+ .custom(isNotEmptyIntArray).withMessage('Should have a valid array of notification ids'),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking markAsReadUserNotificationsValidator parameters', { parameters: req.body })diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.tsindex 73da3142a9..d9e6aa6672 100644--- a/server/middlewares/validators/user-subscriptions.ts+++ b/server/middlewares/validators/user-subscriptions.ts@@ -9,7 +9,9 @@ import { ActorFollowModel } from '../../models/actor/actor-follow'import { areValidationErrors } from './shared'const userSubscriptionListValidator = [- query('search').optional().not().isEmpty().withMessage('Should have a valid search'),+ query('search')+ .optional()+ .not().isEmpty(),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking userSubscriptionListValidator parameters', { parameters: req.query })@@ -21,7 +23,8 @@ const userSubscriptionListValidator = []const userSubscriptionAddValidator = [- body('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),+ body('uri')+ .custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking userSubscriptionAddValidator parameters', { parameters: req.body })@@ -35,7 +38,7 @@ const userSubscriptionAddValidator = [const areSubscriptionsExistValidator = [query('uris').customSanitizer(toArray)- .custom(areValidActorHandles).withMessage('Should have a valid uri array'),+ .custom(areValidActorHandles).withMessage('Should have a valid array of URIs'),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking areSubscriptionsExistValidator parameters', { parameters: req.query })@@ -47,7 +50,8 @@ const areSubscriptionsExistValidator = []const userSubscriptionGetValidator = [- param('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to unfollow'),+ param('uri')+ .custom(isValidActorHandle),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking userSubscriptionGetValidator parameters', { parameters: req.params })diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.tsindex 6d306121ef..c3a07fccd2 100644--- a/server/middlewares/validators/users.ts+++ b/server/middlewares/validators/users.ts@@ -38,7 +38,7 @@ const usersListValidator = [query('blocked').optional().customSanitizer(toBooleanOrNull)- .isBoolean().withMessage('Should be a valid boolean banned state'),+ .isBoolean().withMessage('Should be a valid blocked boolena'),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersList parameters', { parameters: req.query })@@ -50,19 +50,30 @@ const usersListValidator = []const usersAddValidator = [- body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),- body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'),- body('email').isEmail().withMessage('Should have a valid email'),+ body('username')+ .custom(isUserUsernameValid)+ .withMessage('Should have a valid username (lowercase alphanumeric characters)'),+ body('password')+ .custom(isUserPasswordValidOrEmpty),+ body('email')+ .isEmail(),- body('channelName').optional().custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),+ body('channelName')+ .optional()+ .custom(isVideoChannelUsernameValid),- body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),- body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'),+ body('videoQuota')+ .custom(isUserVideoQuotaValid),+ body('videoQuotaDaily')+ .custom(isUserVideoQuotaDailyValid),body('role').customSanitizer(toIntOrNull)- .custom(isUserRoleValid).withMessage('Should have a valid role'),- body('adminFlags').optional().custom(isUserAdminFlagsValid).withMessage('Should have a valid admin flags'),+ .custom(isUserRoleValid),++ body('adminFlags')+ .optional()+ .custom(isUserAdminFlagsValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersAdd parameters', { parameters: omit(req.body, 'password') })@@ -97,19 +108,22 @@ const usersAddValidator = []const usersRegisterValidator = [- body('username').custom(isUserUsernameValid).withMessage('Should have a valid username'),- body('password').custom(isUserPasswordValid).withMessage('Should have a valid password'),- body('email').isEmail().withMessage('Should have a valid email'),+ body('username')+ .custom(isUserUsernameValid),+ body('password')+ .custom(isUserPasswordValid),+ body('email')+ .isEmail(),body('displayName').optional()- .custom(isUserDisplayNameValid).withMessage('Should have a valid display name'),+ .custom(isUserDisplayNameValid),body('channel.name').optional()- .custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),+ .custom(isVideoChannelUsernameValid),body('channel.displayName').optional()- .custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'),+ .custom(isVideoChannelDisplayNameValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersRegister parameters', { parameters: omit(req.body, 'password') })@@ -141,7 +155,8 @@ const usersRegisterValidator = []const usersRemoveValidator = [- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),+ param('id')+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersRemove parameters', { parameters: req.params })@@ -159,8 +174,11 @@ const usersRemoveValidator = []const usersBlockingValidator = [- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),- body('reason').optional().custom(isUserBlockedReasonValid).withMessage('Should have a valid blocking reason'),+ param('id')+ .custom(isIdValid),+ body('reason')+ .optional()+ .custom(isUserBlockedReasonValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersBlocking parameters', { parameters: req.params })@@ -189,19 +207,33 @@ const deleteMeValidator = []const usersUpdateValidator = [- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),-- body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'),- body('email').optional().isEmail().withMessage('Should have a valid email attribute'),- body('emailVerified').optional().isBoolean().withMessage('Should have a valid email verified attribute'),- body('videoQuota').optional().custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),- body('videoQuotaDaily').optional().custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'),- body('pluginAuth').optional(),+ param('id').custom(isIdValid),++ body('password')+ .optional()+ .custom(isUserPasswordValid),+ body('email')+ .optional()+ .isEmail(),+ body('emailVerified')+ .optional()+ .isBoolean(),+ body('videoQuota')+ .optional()+ .custom(isUserVideoQuotaValid),+ body('videoQuotaDaily')+ .optional()+ .custom(isUserVideoQuotaDailyValid),+ body('pluginAuth')+ .optional()+ .exists(),body('role').optional().customSanitizer(toIntOrNull)- .custom(isUserRoleValid).withMessage('Should have a valid role'),- body('adminFlags').optional().custom(isUserAdminFlagsValid).withMessage('Should have a valid admin flags'),+ .custom(isUserRoleValid),+ body('adminFlags')+ .optional()+ .custom(isUserAdminFlagsValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersUpdate parameters', { parameters: req.body })@@ -221,37 +253,37 @@ const usersUpdateValidator = [const usersUpdateMeValidator = [body('displayName').optional()- .custom(isUserDisplayNameValid).withMessage('Should have a valid display name'),+ .custom(isUserDisplayNameValid),body('description').optional()- .custom(isUserDescriptionValid).withMessage('Should have a valid description'),+ .custom(isUserDescriptionValid),body('currentPassword').optional()- .custom(isUserPasswordValid).withMessage('Should have a valid current password'),+ .custom(isUserPasswordValid),body('password').optional()- .custom(isUserPasswordValid).withMessage('Should have a valid password'),+ .custom(isUserPasswordValid),body('email').optional()- .isEmail().withMessage('Should have a valid email attribute'),+ .isEmail(),body('nsfwPolicy').optional()- .custom(isUserNSFWPolicyValid).withMessage('Should have a valid display Not Safe For Work policy'),+ .custom(isUserNSFWPolicyValid),body('autoPlayVideo').optional()- .custom(isUserAutoPlayVideoValid).withMessage('Should have a valid automatically plays video attribute'),+ .custom(isUserAutoPlayVideoValid),body('p2pEnabled').optional().custom(isUserP2PEnabledValid).withMessage('Should have a valid p2p enabled boolean'),body('videoLanguages').optional()- .custom(isUserVideoLanguages).withMessage('Should have a valid video languages attribute'),+ .custom(isUserVideoLanguages),body('videosHistoryEnabled').optional()- .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'),+ .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled boolean'),body('theme').optional()- .custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'),+ .custom(v => isThemeNameValid(v) && isThemeRegistered(v)),body('noInstanceConfigWarningModal').optional()@@ -296,8 +328,11 @@ const usersUpdateMeValidator = []const usersGetValidator = [- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),- query('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'),+ param('id')+ .custom(isIdValid),+ query('withStats')+ .optional()+ .isBoolean().withMessage('Should have a valid withStats boolean'),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersGet parameters', { parameters: req.params })@@ -326,12 +361,12 @@ const usersVideosValidator = [query('isLive').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid live boolean'),+ .custom(isBooleanValid).withMessage('Should have a valid isLive boolean'),query('channelId').optional().customSanitizer(toIntOrNull)- .custom(isIdValid).withMessage('Should have a valid channel id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersVideosValidator parameters', { parameters: req.query })@@ -384,7 +419,8 @@ const ensureUserRegistrationAllowedForIP = []const usersAskResetPasswordValidator = [- body('email').isEmail().not().isEmpty().withMessage('Should have a valid email'),+ body('email')+ .isEmail(),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersAskResetPassword parameters', { parameters: req.body })@@ -403,9 +439,12 @@ const usersAskResetPasswordValidator = []const usersResetPasswordValidator = [- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),- body('verificationString').not().isEmpty().withMessage('Should have a valid verification string'),- body('password').custom(isUserPasswordValid).withMessage('Should have a valid password'),+ param('id')+ .custom(isIdValid),+ body('verificationString')+ .not().isEmpty(),+ body('password')+ .custom(isUserPasswordValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking usersResetPassword parameters', { parameters: req.params })diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.tsindex de11e69f2a..f065f101cc 100644--- a/server/middlewares/validators/videos/video-blacklist.ts+++ b/server/middlewares/validators/videos/video-blacklist.ts@@ -29,7 +29,7 @@ const videosBlacklistAddValidator = [.custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'),body('reason').optional()- .custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'),+ .custom(isVideoBlacklistReasonValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videosBlacklistAdd parameters', { parameters: req.params })diff --git a/server/middlewares/validators/videos/video-captions.ts b/server/middlewares/validators/videos/video-captions.tsindex dfb8fefc5c..fd6dd151a2 100644--- a/server/middlewares/validators/videos/video-captions.ts+++ b/server/middlewares/validators/videos/video-captions.ts@@ -18,7 +18,7 @@ const addVideoCaptionValidator = [isValidVideoIdParam('videoId'),param('captionLanguage')- .custom(isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'),+ .custom(isVideoCaptionLanguageValid).not().isEmpty(),body('captionfile').custom((_, { req }) => isVideoCaptionFile(req.files, 'captionfile'))diff --git a/server/middlewares/validators/videos/video-channel-sync.ts b/server/middlewares/validators/videos/video-channel-sync.tsindex 081f09bba1..18d8d74d20 100644--- a/server/middlewares/validators/videos/video-channel-sync.ts+++ b/server/middlewares/validators/videos/video-channel-sync.ts@@ -20,8 +20,11 @@ export const ensureSyncIsEnabled = (req: express.Request, res: express.Response,}export const videoChannelSyncValidator = [- body('externalChannelUrl').custom(isUrlValid).withMessage('Should have a valid channel url'),- body('videoChannelId').isInt().withMessage('Should have a valid video channel id'),+ body('externalChannelUrl')+ .custom(isUrlValid),++ body('videoChannelId')+ .isInt(),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoChannelSync parameters', { parameters: req.body })diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.tsindex d53c777fac..ad1415691f 100644--- a/server/middlewares/validators/videos/video-channels.ts+++ b/server/middlewares/validators/videos/video-channels.ts@@ -19,10 +19,16 @@ import { areValidationErrors, checkUserQuota, doesVideoChannelNameWithHostExistimport { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs'export const videoChannelsAddValidator = [- body('name').custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),- body('displayName').custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'),- body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'),- body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'),+ body('name')+ .custom(isVideoChannelUsernameValid),+ body('displayName')+ .custom(isVideoChannelDisplayNameValid),+ body('description')+ .optional()+ .custom(isVideoChannelDescriptionValid),+ body('support')+ .optional()+ .custom(isVideoChannelSupportValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body })@@ -49,16 +55,18 @@ export const videoChannelsAddValidator = []export const videoChannelsUpdateValidator = [- param('nameWithHost').exists().withMessage('Should have an video channel name with host'),+ param('nameWithHost')+ .exists(),+body('displayName').optional()- .custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'),+ .custom(isVideoChannelDisplayNameValid),body('description').optional()- .custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'),+ .custom(isVideoChannelDescriptionValid),body('support').optional()- .custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'),+ .custom(isVideoChannelSupportValid),body('bulkVideosSupportUpdate').optional().custom(isBooleanValid).withMessage('Should have a valid bulkVideosSupportUpdate boolean field'),@@ -83,7 +91,8 @@ export const videoChannelsRemoveValidator = []export const videoChannelsNameWithHostValidator = [- param('nameWithHost').exists().withMessage('Should have an video channel name with host'),+ param('nameWithHost')+ .exists(),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoChannelsNameWithHostValidator parameters', { parameters: req.params })@@ -124,7 +133,7 @@ export const videoChannelStatsValidator = [query('withStats').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid stats flag'),+ .custom(isBooleanValid).withMessage('Should have a valid stats flag boolean'),(req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return@@ -133,7 +142,9 @@ export const videoChannelStatsValidator = []export const videoChannelsListValidator = [- query('search').optional().not().isEmpty().withMessage('Should have a valid search'),+ query('search')+ .optional()+ .not().isEmpty(),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking video channels search query', { parameters: req.query })@@ -145,11 +156,12 @@ export const videoChannelsListValidator = []export const videoChannelImportVideosValidator = [- body('externalChannelUrl').custom(isUrlValid).withMessage('Should have a valid channel url'),+ body('externalChannelUrl')+ .custom(isUrlValid),body('videoChannelSyncId').optional()- .custom(isIdValid).withMessage('Should have a valid channel sync id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoChannelImport parameters', { parameters: req.body })diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.tsindex 68f41e50e5..b2a39617b5 100644--- a/server/middlewares/validators/videos/video-comments.ts+++ b/server/middlewares/validators/videos/video-comments.ts@@ -19,28 +19,28 @@ import {const listVideoCommentsValidator = [query('isLocal')- .optional()- .customSanitizer(toBooleanOrNull)- .custom(isBooleanValid)- .withMessage('Should have a valid is local boolean'),+ .optional()+ .customSanitizer(toBooleanOrNull)+ .custom(isBooleanValid)+ .withMessage('Should have a valid isLocal boolean'),query('onLocalVideo')- .optional()- .customSanitizer(toBooleanOrNull)- .custom(isBooleanValid)- .withMessage('Should have a valid is on local video boolean'),+ .optional()+ .customSanitizer(toBooleanOrNull)+ .custom(isBooleanValid)+ .withMessage('Should have a valid onLocalVideo boolean'),query('search').optional()- .custom(exists).withMessage('Should have a valid search'),+ .custom(exists),query('searchAccount').optional()- .custom(exists).withMessage('Should have a valid account search'),+ .custom(exists),query('searchVideo').optional()- .custom(exists).withMessage('Should have a valid video search'),+ .custom(exists),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking listVideoCommentsValidator parameters.', { parameters: req.query })@@ -70,7 +70,7 @@ const listVideoThreadCommentsValidator = [isValidVideoIdParam('videoId'),param('threadId')- .custom(isIdValid).not().isEmpty().withMessage('Should have a valid threadId'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking listVideoThreadComments parameters.', { parameters: req.params })@@ -89,7 +89,7 @@ const addVideoCommentThreadValidator = [isValidVideoIdParam('videoId'),body('text')- .custom(isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'),+ .custom(isValidVideoCommentText),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking addVideoCommentThread parameters.', { parameters: req.params, body: req.body })@@ -109,9 +109,9 @@ const addVideoCommentThreadValidator = [const addVideoCommentReplyValidator = [isValidVideoIdParam('videoId'),- param('commentId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'),+ param('commentId').custom(isIdValid),- body('text').custom(isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'),+ body('text').custom(isValidVideoCommentText),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking addVideoCommentReply parameters.', { parameters: req.params, body: req.body })@@ -133,7 +133,7 @@ const videoCommentGetValidator = [isValidVideoIdParam('videoId'),param('commentId')- .custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params })@@ -149,7 +149,8 @@ const videoCommentGetValidator = [const removeVideoCommentValidator = [isValidVideoIdParam('videoId'),- param('commentId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'),+ param('commentId')+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking removeVideoCommentValidator parameters.', { parameters: req.params })diff --git a/server/middlewares/validators/videos/video-files.ts b/server/middlewares/validators/videos/video-files.tsindex b3db3f4f74..b44c997e3d 100644--- a/server/middlewares/validators/videos/video-files.ts+++ b/server/middlewares/validators/videos/video-files.ts@@ -41,7 +41,7 @@ const videoFilesDeleteWebTorrentFileValidator = [isValidVideoIdParam('id'),param('videoFileId')- .custom(isIdValid).withMessage('Should have a valid file id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoFilesDeleteWebTorrentFile parameters', { parameters: req.params })@@ -109,7 +109,7 @@ const videoFilesDeleteHLSFileValidator = [isValidVideoIdParam('id'),param('videoFileId')- .custom(isIdValid).withMessage('Should have a valid file id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoFilesDeleteHLSFile parameters', { parameters: req.params })diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.tsindex 3115acb21a..0ab9e6e6f7 100644--- a/server/middlewares/validators/videos/video-imports.ts+++ b/server/middlewares/validators/videos/video-imports.ts@@ -19,13 +19,13 @@ import { getCommonVideoEditAttributes } from './videos'const videoImportAddValidator = getCommonVideoEditAttributes().concat([body('channelId').customSanitizer(toIntOrNull)- .custom(isIdValid).withMessage('Should have correct video channel id'),+ .custom(isIdValid),body('targetUrl').optional()- .custom(isVideoImportTargetUrlValid).withMessage('Should have a valid video import target URL'),+ .custom(isVideoImportTargetUrlValid),body('magnetUri').optional()- .custom(isVideoMagnetUriValid).withMessage('Should have a valid video magnet URI'),+ .custom(isVideoMagnetUriValid),body('torrentfile').custom((value, { req }) => isVideoImportTorrentFile(req.files)).withMessage(@@ -95,7 +95,7 @@ const videoImportAddValidator = getCommonVideoEditAttributes().concat([const getMyVideoImportsValidator = [query('videoChannelSyncId').optional()- .custom(isIdValid).withMessage('Should have correct videoChannelSync id'),+ .custom(isIdValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking getMyVideoImportsValidator parameters', { parameters: req.params })@@ -108,7 +108,7 @@ const getMyVideoImportsValidator = [const videoImportDeleteValidator = [param('id')- .custom(isIdValid).withMessage('Should have correct import id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoImportDeleteValidator parameters', { parameters: req.params })@@ -131,7 +131,7 @@ const videoImportDeleteValidator = [const videoImportCancelValidator = [param('id')- .custom(isIdValid).withMessage('Should have correct import id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoImportCancelValidator parameters', { parameters: req.params })diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.tsindex 777b57e9aa..a330d70a19 100644--- a/server/middlewares/validators/videos/video-live.ts+++ b/server/middlewares/validators/videos/video-live.ts@@ -56,7 +56,7 @@ const videoLiveGetValidator = [const videoLiveAddValidator = getCommonVideoEditAttributes().concat([body('channelId').customSanitizer(toIntOrNull)- .custom(isIdValid).withMessage('Should have correct video channel id'),+ .custom(isIdValid),body('name').custom(isVideoNameValid).withMessage(@@ -66,18 +66,17 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([body('saveReplay').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid saveReplay attribute'),+ .custom(isBooleanValid).withMessage('Should have a valid saveReplay boolean'),body('permanentLive').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid permanentLive attribute'),+ .custom(isBooleanValid).withMessage('Should have a valid permanentLive boolean'),body('latencyMode').optional().customSanitizer(toIntOrNull)- .custom(isLiveLatencyModeValid)- .withMessage('Should have a valid latency mode attribute'),+ .custom(isLiveLatencyModeValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoLiveAddValidator parameters', { parameters: req.body })@@ -156,13 +155,12 @@ const videoLiveUpdateValidator = [body('saveReplay').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid saveReplay attribute'),+ .custom(isBooleanValid).withMessage('Should have a valid saveReplay boolean'),body('latencyMode').optional().customSanitizer(toIntOrNull)- .custom(isLiveLatencyModeValid)- .withMessage('Should have a valid latency mode attribute'),+ .custom(isLiveLatencyModeValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoLiveUpdateValidator parameters', { parameters: req.body })diff --git a/server/middlewares/validators/videos/video-ownership-changes.ts b/server/middlewares/validators/videos/video-ownership-changes.tsindex 6dcdc05f5c..e73196f5b6 100644--- a/server/middlewares/validators/videos/video-ownership-changes.ts+++ b/server/middlewares/validators/videos/video-ownership-changes.ts@@ -41,7 +41,7 @@ const videosChangeOwnershipValidator = [const videosTerminateChangeOwnershipValidator = [param('id')- .custom(isIdValid).withMessage('Should have a valid id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking changeOwnership parameters', { parameters: req.params })diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.tsindex d514ae0ad1..42e6646f9a 100644--- a/server/middlewares/validators/videos/video-playlists.ts+++ b/server/middlewares/validators/videos/video-playlists.ts@@ -45,7 +45,7 @@ import {const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([body('displayName')- .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'),+ .custom(isVideoPlaylistNameValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body })@@ -73,7 +73,7 @@ const videoPlaylistsUpdateValidator = getCommonPlaylistEditAttributes().concat([body('displayName').optional()- .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'),+ .custom(isVideoPlaylistNameValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body })@@ -184,7 +184,9 @@ const videoPlaylistsGetValidator = (fetchType: VideoPlaylistFetchType) => {}const videoPlaylistsSearchValidator = [- query('search').optional().not().isEmpty().withMessage('Should have a valid search'),+ query('search')+ .optional()+ .not().isEmpty(),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoPlaylists search query', { parameters: req.query })@@ -200,13 +202,13 @@ const videoPlaylistsAddVideoValidator = [body('videoId').customSanitizer(toCompleteUUID)- .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid'),+ .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid/short uuid'),body('startTimestamp').optional()- .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'),+ .custom(isVideoPlaylistTimestampValid),body('stopTimestamp').optional()- .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'),+ .custom(isVideoPlaylistTimestampValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoPlaylistsAddVideoValidator parameters', { parameters: req.params })@@ -230,13 +232,13 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [isValidPlaylistIdParam('playlistId'),param('playlistElementId').customSanitizer(toCompleteUUID)- .custom(isIdValid).withMessage('Should have an element id/uuid'),+ .custom(isIdValid).withMessage('Should have an element id/uuid/short uuid'),body('startTimestamp').optional()- .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'),+ .custom(isVideoPlaylistTimestampValid),body('stopTimestamp').optional()- .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'),+ .custom(isVideoPlaylistTimestampValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoPlaylistsRemoveVideoValidator parameters', { parameters: req.params })@@ -266,7 +268,7 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [const videoPlaylistElementAPGetValidator = [isValidPlaylistIdParam('playlistId'),param('playlistElementId')- .custom(isIdValid).withMessage('Should have an playlist element id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params })@@ -300,13 +302,14 @@ const videoPlaylistElementAPGetValidator = [const videoPlaylistsReorderVideosValidator = [isValidPlaylistIdParam('playlistId'),+body('startPosition')- .isInt({ min: 1 }).withMessage('Should have a valid start position'),+ .isInt({ min: 1 }),body('insertAfterPosition')- .isInt({ min: 0 }).withMessage('Should have a valid insert after position'),+ .isInt({ min: 0 }),body('reorderLength').optional()- .isInt({ min: 1 }).withMessage('Should have a valid range length'),+ .isInt({ min: 1 }),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoPlaylistsReorderVideosValidator parameters', { parameters: req.params })@@ -340,7 +343,7 @@ const videoPlaylistsReorderVideosValidator = [const commonVideoPlaylistFiltersValidator = [query('playlistType').optional()- .custom(isVideoPlaylistTypeValid).withMessage('Should have a valid playlist type'),+ .custom(isVideoPlaylistTypeValid),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking commonVideoPlaylistFiltersValidator parameters', { parameters: req.params })@@ -399,11 +402,11 @@ function getCommonPlaylistEditAttributes () {body('description').optional().customSanitizer(toValueOrNull)- .custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'),+ .custom(isVideoPlaylistDescriptionValid),body('privacy').optional().customSanitizer(toIntOrNull)- .custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'),+ .custom(isVideoPlaylistPrivacyValid),body('videoChannelId').optional().customSanitizer(toIntOrNull)diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.tsindex 8b8eeedb6d..0c02baafb9 100644--- a/server/middlewares/validators/videos/video-rates.ts+++ b/server/middlewares/validators/videos/video-rates.ts@@ -13,7 +13,8 @@ import { areValidationErrors, checkCanSeeVideo, doesVideoExist, isValidVideoIdPaconst videoUpdateRateValidator = [isValidVideoIdParam('id'),- body('rating').custom(isVideoRatingTypeValid).withMessage('Should have a valid rate type'),+ body('rating')+ .custom(isVideoRatingTypeValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoRate parameters', { parameters: req.body })@@ -29,8 +30,10 @@ const videoUpdateRateValidator = [const getAccountVideoRateValidatorFactory = function (rateType: VideoRateType) {return [- param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),- param('videoId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid videoId'),+ param('name')+ .custom(isAccountNameValid),+ param('videoId')+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params })@@ -53,7 +56,9 @@ const getAccountVideoRateValidatorFactory = function (rateType: VideoRateType) {}const videoRatingValidator = [- query('rating').optional().custom(isRatingValid).withMessage('Value must be one of "like" or "dislike"'),+ query('rating')+ .optional()+ .custom(isRatingValid).withMessage('Value must be one of "like" or "dislike"'),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking rating parameter', { parameters: req.params })diff --git a/server/middlewares/validators/videos/video-shares.ts b/server/middlewares/validators/videos/video-shares.tsindex 0f04032bb3..40337dcf11 100644--- a/server/middlewares/validators/videos/video-shares.ts+++ b/server/middlewares/validators/videos/video-shares.ts@@ -10,7 +10,7 @@ const videosShareValidator = [isValidVideoIdParam('id'),param('actorId')- .custom(isIdValid).not().isEmpty().withMessage('Should have a valid actor id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoShare parameters', { parameters: req.params })diff --git a/server/middlewares/validators/videos/video-stats.ts b/server/middlewares/validators/videos/video-stats.tsindex f17fbcc095..ddbf2a5645 100644--- a/server/middlewares/validators/videos/video-stats.ts+++ b/server/middlewares/validators/videos/video-stats.ts@@ -12,13 +12,11 @@ const videoOverallStatsValidator = [query('startDate').optional()- .custom(isDateValid)- .withMessage('Should have a valid start date'),+ .custom(isDateValid),query('endDate').optional()- .custom(isDateValid)- .withMessage('Should have a valid end date'),+ .custom(isDateValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoOverallStatsValidator parameters', { parameters: req.body })@@ -54,18 +52,15 @@ const videoTimeserieStatsValidator = [isValidVideoIdParam('videoId'),param('metric')- .custom(isValidStatTimeserieMetric)- .withMessage('Should have a valid timeserie metric'),+ .custom(isValidStatTimeserieMetric),query('startDate').optional()- .custom(isDateValid)- .withMessage('Should have a valid start date'),+ .custom(isDateValid),query('endDate').optional()- .custom(isDateValid)- .withMessage('Should have a valid end date'),+ .custom(isDateValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoTimeserieStatsValidator parameters', { parameters: req.body })diff --git a/server/middlewares/validators/videos/video-studio.ts b/server/middlewares/validators/videos/video-studio.tsindex af7fe22838..d07e150aef 100644--- a/server/middlewares/validators/videos/video-studio.ts+++ b/server/middlewares/validators/videos/video-studio.ts@@ -16,9 +16,11 @@ import { logger } from '../../../helpers/logger'import { areValidationErrors, checkUserCanManageVideo, checkUserQuota, doesVideoExist } from '../shared'const videoStudioAddEditionValidator = [- param('videoId').custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid'),+ param('videoId')+ .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid/short uuid'),- body('tasks').custom(isValidStudioTasksArray).withMessage('Should have a valid array of tasks'),+ body('tasks')+ .custom(isValidStudioTasksArray).withMessage('Should have a valid array of tasks'),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoStudioAddEditionValidator parameters.', { parameters: req.params, body: req.body, files: req.files })diff --git a/server/middlewares/validators/videos/video-transcoding.ts b/server/middlewares/validators/videos/video-transcoding.tsindex da6638f4d0..36b9799e6f 100644--- a/server/middlewares/validators/videos/video-transcoding.ts+++ b/server/middlewares/validators/videos/video-transcoding.ts@@ -11,7 +11,7 @@ const createTranscodingValidator = [isValidVideoIdParam('videoId'),body('transcodingType')- .custom(isValidCreateTranscodingType).withMessage('Should have a valid transcoding type'),+ .custom(isValidCreateTranscodingType),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking createTranscodingValidator parameters', { parameters: req.body })diff --git a/server/middlewares/validators/videos/video-view.ts b/server/middlewares/validators/videos/video-view.tsindex 2edcd140f7..4927c04ad6 100644--- a/server/middlewares/validators/videos/video-view.ts+++ b/server/middlewares/validators/videos/video-view.ts@@ -10,7 +10,7 @@ import { getCachedVideoDuration } from '@server/lib/video'const getVideoLocalViewerValidator = [param('localViewerId')- .custom(isIdValid).withMessage('Should have a valid local viewer id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking getVideoLocalViewerValidator parameters', { parameters: req.params })@@ -37,7 +37,7 @@ const videoViewValidator = [body('currentTime').optional() // TODO: remove optional in a few versions, introduced in 4.2.customSanitizer(toIntOrNull)- .custom(isIntOrNull).withMessage('Should have correct current time'),+ .custom(isIntOrNull),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videoView parameters', { parameters: req.body })diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.tsindex c6d31f8f05..5e8e25a9c7 100644--- a/server/middlewares/validators/videos/videos.ts+++ b/server/middlewares/validators/videos/videos.ts@@ -69,7 +69,7 @@ const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([),body('channelId').customSanitizer(toIntOrNull)- .custom(isIdValid).withMessage('Should have correct video channel id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files })@@ -167,9 +167,7 @@ const videosAddResumableValidator = [*/const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([body('filename')- .isString()- .exists()- .withMessage('Should have a valid filename'),+ .exists(),body('name').trim().custom(isVideoNameValid).withMessage(@@ -177,7 +175,7 @@ const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([),body('channelId').customSanitizer(toIntOrNull)- .custom(isIdValid).withMessage('Should have correct video channel id'),+ .custom(isIdValid),header('x-upload-content-length').isNumeric()@@ -230,7 +228,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([body('channelId').optional().customSanitizer(toIntOrNull)- .custom(isIdValid).withMessage('Should have correct video channel id'),+ .custom(isIdValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking videosUpdate parameters', { parameters: req.body })@@ -341,8 +339,7 @@ const videosRemoveValidator = [const videosOverviewValidator = [query('page').optional()- .isInt({ min: 1, max: OVERVIEWS.VIDEOS.SAMPLES_COUNT })- .withMessage('Should have a valid pagination'),+ .isInt({ min: 1, max: OVERVIEWS.VIDEOS.SAMPLES_COUNT }),(req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return@@ -367,35 +364,35 @@ function getCommonVideoEditAttributes () {body('category').optional().customSanitizer(toIntOrNull)- .custom(isVideoCategoryValid).withMessage('Should have a valid category'),+ .custom(isVideoCategoryValid),body('licence').optional().customSanitizer(toIntOrNull)- .custom(isVideoLicenceValid).withMessage('Should have a valid licence'),+ .custom(isVideoLicenceValid),body('language').optional().customSanitizer(toValueOrNull)- .custom(isVideoLanguageValid).withMessage('Should have a valid language'),+ .custom(isVideoLanguageValid),body('nsfw').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'),+ .custom(isBooleanValid).withMessage('Should have a valid nsfw boolean'),body('waitTranscoding').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid wait transcoding attribute'),+ .custom(isBooleanValid).withMessage('Should have a valid waitTranscoding boolean'),body('privacy').optional().customSanitizer(toValueOrNull)- .custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'),+ .custom(isVideoPrivacyValid),body('description').optional().customSanitizer(toValueOrNull)- .custom(isVideoDescriptionValid).withMessage('Should have a valid description'),+ .custom(isVideoDescriptionValid),body('support').optional().customSanitizer(toValueOrNull)- .custom(isVideoSupportValid).withMessage('Should have a valid support text'),+ .custom(isVideoSupportValid),body('tags').optional().customSanitizer(toValueOrNull)@@ -407,15 +404,15 @@ function getCommonVideoEditAttributes () {body('commentsEnabled').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have comments enabled boolean'),+ .custom(isBooleanValid).withMessage('Should have commentsEnabled boolean'),body('downloadEnabled').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'),+ .custom(isBooleanValid).withMessage('Should have downloadEnabled boolean'),body('originallyPublishedAt').optional().customSanitizer(toValueOrNull)- .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'),+ .custom(isVideoOriginallyPublishedAtValid),body('scheduleUpdate').optional().customSanitizer(toValueOrNull),@@ -425,7 +422,7 @@ function getCommonVideoEditAttributes () {body('scheduleUpdate.privacy').optional().customSanitizer(toIntOrNull)- .custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy')+ .custom(isScheduleVideoUpdatePrivacyValid)] as (ValidationChain | ExpressPromiseHandler)[]}@@ -433,59 +430,59 @@ const commonVideosFiltersValidator = [query('categoryOneOf').optional().customSanitizer(toArray)- .custom(isNumberArray).withMessage('Should have a valid one of category array'),+ .custom(isNumberArray).withMessage('Should have a valid categoryOneOf array'),query('licenceOneOf').optional().customSanitizer(toArray)- .custom(isNumberArray).withMessage('Should have a valid one of licence array'),+ .custom(isNumberArray).withMessage('Should have a valid licenceOneOf array'),query('languageOneOf').optional().customSanitizer(toArray)- .custom(isStringArray).withMessage('Should have a valid one of language array'),+ .custom(isStringArray).withMessage('Should have a valid languageOneOf array'),query('privacyOneOf').optional().customSanitizer(toArray)- .custom(isNumberArray).withMessage('Should have a valid one of privacy array'),+ .custom(isNumberArray).withMessage('Should have a valid privacyOneOf array'),query('tagsOneOf').optional().customSanitizer(toArray)- .custom(isStringArray).withMessage('Should have a valid one of tags array'),+ .custom(isStringArray).withMessage('Should have a valid tagsOneOf array'),query('tagsAllOf').optional().customSanitizer(toArray)- .custom(isStringArray).withMessage('Should have a valid all of tags array'),+ .custom(isStringArray).withMessage('Should have a valid tagsAllOf array'),query('nsfw').optional()- .custom(isBooleanBothQueryValid).withMessage('Should have a valid NSFW attribute'),+ .custom(isBooleanBothQueryValid),query('isLive').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid live boolean'),+ .custom(isBooleanValid).withMessage('Should have a valid isLive boolean'),query('filter').optional()- .custom(isVideoFilterValid).withMessage('Should have a valid filter attribute'),+ .custom(isVideoFilterValid),query('include').optional()- .custom(isVideoIncludeValid).withMessage('Should have a valid include attribute'),+ .custom(isVideoIncludeValid),query('isLocal').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid local boolean'),+ .custom(isBooleanValid).withMessage('Should have a valid isLocal boolean'),query('hasHLSFiles').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid has hls boolean'),+ .custom(isBooleanValid).withMessage('Should have a valid hasHLSFiles boolean'),query('hasWebtorrentFiles').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid has webtorrent boolean'),+ .custom(isBooleanValid).withMessage('Should have a valid hasWebtorrentFiles boolean'),query('skipCount').optional().customSanitizer(toBooleanOrNull)- .custom(isBooleanValid).withMessage('Should have a valid skip count boolean'),+ .custom(isBooleanValid).withMessage('Should have a valid skipCount boolean'),query('search').optional()- .custom(exists).withMessage('Should have a valid search'),+ .custom(exists),(req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking commons video filters query', { parameters: req.query })diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.tsindex 8893a0c7e8..4c176f1626 100644--- a/server/middlewares/validators/webfinger.ts+++ b/server/middlewares/validators/webfinger.ts@@ -8,7 +8,8 @@ import { ActorModel } from '../../models/actor/actor'import { areValidationErrors } from './shared'const webfingerValidator = [- query('resource').custom(isWebfingerLocalResourceValid).withMessage('Should have a valid webfinger resource'),+ query('resource')+ .custom(isWebfingerLocalResourceValid),async (req: express.Request, res: express.Response, next: express.NextFunction) => {logger.debug('Checking webfinger parameters', { parameters: req.query })