import { getServerActor } from '@server/models/application/application'
import { ExpressPromiseHandler } from '@server/types/express-handler'
import { MUserAccountId, MVideoFullLight } from '@server/types/models'
-import { getAllPrivacies } from '@shared/core-utils'
+import { arrayify, getAllPrivacies } from '@shared/core-utils'
import { HttpStatusCode, ServerErrorCode, UserRight, VideoInclude } from '@shared/models'
import {
exists,
isDateValid,
isFileValid,
isIdValid,
- toArray,
toBooleanOrNull,
toIntOrNull,
toValueOrNull
.custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files })
-
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
const videoFile: express.VideoUploadFile = req.files['videofile'][0]
files: req.files
})
- if (areValidationErrors(req, res)) return cleanup()
+ if (areValidationErrors(req, res, { omitLog: true })) return cleanup()
const files = { videofile: [ videoFileMetadata ] }
if (!await commonVideoChecksPass({ req, res, user, videoFileSize: videoFileMetadata.size, files })) return cleanup()
.custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking videosUpdate parameters', { parameters: req.body })
-
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
if (areErrorsInScheduleUpdate(req, res)) return cleanUpReqFiles(req)
if (!await doesVideoExist(req.params.id, res)) return cleanUpReqFiles(req)
isValidVideoIdParam('id'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking videosGet parameters', { parameters: req.params })
-
if (areValidationErrors(req, res)) return
if (!await doesVideoExist(req.params.id, res, fetchType)) return
.custom(isIdValid).not().isEmpty().withMessage('Should have a valid videoFileId'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking videoFileMetadataGet parameters', { parameters: req.params })
-
if (areValidationErrors(req, res)) return
if (!await doesVideoFileOfVideoExist(+req.params.videoFileId, req.params.id, res)) return
isValidVideoIdParam('id'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking videosRemove parameters', { parameters: req.params })
-
if (areValidationErrors(req, res)) return
if (!await doesVideoExist(req.params.id, res)) return
const commonVideosFiltersValidator = [
query('categoryOneOf')
.optional()
- .customSanitizer(toArray)
+ .customSanitizer(arrayify)
.custom(isNumberArray).withMessage('Should have a valid categoryOneOf array'),
query('licenceOneOf')
.optional()
- .customSanitizer(toArray)
+ .customSanitizer(arrayify)
.custom(isNumberArray).withMessage('Should have a valid licenceOneOf array'),
query('languageOneOf')
.optional()
- .customSanitizer(toArray)
+ .customSanitizer(arrayify)
.custom(isStringArray).withMessage('Should have a valid languageOneOf array'),
query('privacyOneOf')
.optional()
- .customSanitizer(toArray)
+ .customSanitizer(arrayify)
.custom(isNumberArray).withMessage('Should have a valid privacyOneOf array'),
query('tagsOneOf')
.optional()
- .customSanitizer(toArray)
+ .customSanitizer(arrayify)
.custom(isStringArray).withMessage('Should have a valid tagsOneOf array'),
query('tagsAllOf')
.optional()
- .customSanitizer(toArray)
+ .customSanitizer(arrayify)
.custom(isStringArray).withMessage('Should have a valid tagsAllOf array'),
query('nsfw')
.optional()
.custom(exists),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
- logger.debug('Checking commons video filters query', { parameters: req.query })
-
if (areValidationErrors(req, res)) return
// FIXME: deprecated in 4.0, to remove