import { ExpressPromiseHandler } from '@server/types/express-handler'
import { MUserAccountId, MVideoFullLight } from '@server/types/models'
import { arrayify, getAllPrivacies } from '@shared/core-utils'
+import { getVideoStreamDuration } from '@shared/ffmpeg'
import { HttpStatusCode, ServerErrorCode, UserRight, VideoInclude, VideoState } from '@shared/models'
import {
exists,
isVideoSupportValid
} from '../../../helpers/custom-validators/videos'
import { cleanUpReqFiles } from '../../../helpers/express-utils'
-import { getVideoStreamDuration } from '../../../helpers/ffmpeg'
import { logger } from '../../../helpers/logger'
import { deleteFileAndCatch } from '../../../helpers/utils'
import { getVideoWithAttributes } from '../../../helpers/video'
if (!await doesVideoExist(req.params.id, res)) return cleanUpReqFiles(req)
const video = getVideoWithAttributes(res)
- if (req.body.privacy && video.isLive && video.state !== VideoState.WAITING_FOR_LIVE) {
+ if (video.isLive && video.privacy !== req.body.privacy && video.state !== VideoState.WAITING_FOR_LIVE) {
return res.fail({ message: 'Cannot update privacy of a live that has already started' })
}
query('search')
.optional()
.custom(exists),
+ query('excludeAlreadyWatched')
+ .optional()
+ .customSanitizer(toBooleanOrNull)
+ .isBoolean().withMessage('Should be a valid excludeAlreadyWatched boolean'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
}
}
+ if (!user && exists(req.query.excludeAlreadyWatched)) {
+ res.fail({
+ status: HttpStatusCode.BAD_REQUEST_400,
+ message: 'Cannot use excludeAlreadyWatched parameter when auth token is not provided'
+ })
+ return false
+ }
return next()
}
]