Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix video file accept plugin filter metadata

Chocobozzz7dc7235386a4
diff --git a/packages/server-commands/src/videos/videos-command.ts b/packages/server-commands/src/videos/videos-command.ts
index a309a4efb5..58e714d467 100644
--- a/packages/server-commands/src/videos/videos-command.ts
+++ b/packages/server-commands/src/videos/videos-command.ts
@@ -432,7 +432,7 @@ export class VideosCommand extends AbstractCommand {
completedExpectedStatus?: HttpStatusCodeType
videoChannelId?: number
} = {}) {
- const { mode = 'legacy', videoChannelId, waitTorrentGeneration = true } = options
+ const { mode = 'legacy', videoChannelId, completedExpectedStatus = HttpStatusCode.OK_200, waitTorrentGeneration = true } = options
let defaultChannelId = 1
if (!videoChannelId) {
@@ -474,7 +474,7 @@ export class VideosCommand extends AbstractCommand {
// Wait torrent generation
const expectedStatus = this.buildExpectedStatus({ ...options, defaultExpectedStatus: HttpStatusCode.OK_200 })
- if (expectedStatus === HttpStatusCode.OK_200 && waitTorrentGeneration) {
+ if (expectedStatus === HttpStatusCode.OK_200 && completedExpectedStatus === HttpStatusCode.OK_200 && waitTorrentGeneration) {
let video: VideoDetails
do {
diff --git a/server/core/middlewares/validators/videos/shared/video-validators.ts b/server/core/middlewares/validators/videos/shared/video-validators.ts
index ab8c77e087..65dec12620 100644
--- a/server/core/middlewares/validators/videos/shared/video-validators.ts
+++ b/server/core/middlewares/validators/videos/shared/video-validators.ts
@@ -46,14 +46,15 @@ export async function commonVideoFileChecks (options: {
export async function isVideoFileAccepted (options: {
req: express.Request
res: express.Response
+ videoBody: Record<string, any>
videoFile: express.VideoLegacyUploadFile
hook: Extract<ServerFilterHookName, 'filter:api.video.upload.accept.result' | 'filter:api.video.update-file.accept.result'>
}) {
- const { req, res, videoFile, hook } = options
+ const { req, res, videoBody, videoFile, hook } = options
// Check we accept this video
const acceptParameters = {
- videoBody: req.body,
+ videoBody,
videoFile,
user: res.locals.oauth.token.User
}
diff --git a/server/core/middlewares/validators/videos/video-source.ts b/server/core/middlewares/validators/videos/video-source.ts
index 47c6d3857f..e88d27357e 100644
--- a/server/core/middlewares/validators/videos/video-source.ts
+++ b/server/core/middlewares/validators/videos/video-source.ts
@@ -56,7 +56,15 @@ export const replaceVideoSourceResumableValidator = [
return cleanup()
}
- if (!await isVideoFileAccepted({ req, res, videoFile: file, hook: 'filter:api.video.update-file.accept.result' })) {
+ if (
+ !await isVideoFileAccepted({
+ req,
+ res,
+ videoFile: file,
+ videoBody: file.metadata,
+ hook: 'filter:api.video.update-file.accept.result'
+ })
+ ) {
return cleanup()
}
diff --git a/server/core/middlewares/validators/videos/videos.ts b/server/core/middlewares/validators/videos/videos.ts
index 0fd4da838e..99c3b85933 100644
--- a/server/core/middlewares/validators/videos/videos.ts
+++ b/server/core/middlewares/validators/videos/videos.ts
@@ -108,7 +108,7 @@ export const videosAddLegacyValidator = [
!await commonVideoChecks({ req, res, videoFileSize: videoFile.size, files: req.files }) ||
!isValidPasswordProtectedPrivacy(req, res) ||
!await addDurationToVideoFileIfNeeded({ videoFile, res, middlewareName: 'videosAddLegacyValidator' }) ||
- !await isVideoFileAccepted({ req, res, videoFile, hook: 'filter:api.video.upload.accept.result' })
+ !await isVideoFileAccepted({ req, res, videoBody: req.body, videoFile, hook: 'filter:api.video.upload.accept.result' })
) {
return cleanUpReqFiles(req)
}
@@ -151,7 +151,16 @@ export const videosAddResumableValidator = [
}
if (!await addDurationToVideoFileIfNeeded({ videoFile: file, res, middlewareName: 'videosAddResumableValidator' })) return cleanup()
- if (!await isVideoFileAccepted({ req, res, videoFile: file, hook: 'filter:api.video.upload.accept.result' })) return cleanup()
+
+ if (
+ !await isVideoFileAccepted({
+ req,
+ res,
+ videoFile: file,
+ videoBody: file.metadata,
+ hook: 'filter:api.video.upload.accept.result'
+ })
+ ) return cleanup()
res.locals.uploadVideoFileResumable = { ...file, originalname: file.filename }