From d1936e9ef6f04e9bfcd00bb10b6eb821efe5e0b3 Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Wed, 15 May 2024 10:48:49 -0700 Subject: [PATCH] fix: change to nullable create/patch stream (#2179) * fix: change to nullable create/patch stream * feat: added nullable to asset profiles field * api: Handle null profiles appropriately --------- Co-authored-by: Victor Elias --- packages/api/src/controllers/asset.ts | 5 +++-- packages/api/src/controllers/stream.ts | 2 +- packages/api/src/schema/api-schema.yaml | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/api/src/controllers/asset.ts b/packages/api/src/controllers/asset.ts index 178baac525..edc1b16b1f 100644 --- a/packages/api/src/controllers/asset.ts +++ b/packages/api/src/controllers/asset.ts @@ -862,7 +862,7 @@ const uploadWithUrlHandler: RequestHandler = async (req, res) => { "vod-thumbs-off", req.user?.id )), - profiles, + ...(profiles ? { profiles } : null), // avoid serializing null profiles on the task, targetSegmentSizeSecs, }, }, @@ -897,7 +897,7 @@ app.post( let playbackId = await generateUniquePlaybackId(id); const { vodObjectStoreId, jwtSecret, jwtAudience } = req.config; - const { encryption, c2pa } = req.body as NewAssetPayload; + const { encryption, c2pa, profiles } = req.body as NewAssetPayload; if (encryption) { if (encryption.encryptedKey) { if (!isValidBase64(encryption.encryptedKey)) { @@ -944,6 +944,7 @@ app.post( catalystPipelineStrategy: catalystPipelineStrategy(req), encryption, c2pa, + ...(profiles ? { profiles } : null), // avoid serializing null profiles on the task }, }, null, diff --git a/packages/api/src/controllers/stream.ts b/packages/api/src/controllers/stream.ts index ff3a0c3a10..c871b7d3c6 100644 --- a/packages/api/src/controllers/stream.ts +++ b/packages/api/src/controllers/stream.ts @@ -1358,8 +1358,8 @@ async function handleCreateStream(req: Request, payload: NewStreamPayload) { } let doc: DBStream = { - profiles: req.config.defaultStreamProfiles, ...payload, + profiles: payload.profiles || req.config.defaultStreamProfiles, kind: "stream", userId: req.user.id, creatorId: mapInputCreatorId(payload.creatorId), diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index cc2cf0db12..fd512dbc97 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -661,7 +661,11 @@ components: playbackPolicy: $ref: "#/components/schemas/playback-policy" profiles: - $ref: "#/components/schemas/stream/properties/profiles" + type: + - array + - "null" + items: + $ref: "#/components/schemas/ffmpeg-profile" record: $ref: "#/components/schemas/stream/properties/record" multistream: @@ -695,7 +699,11 @@ components: playbackPolicy: $ref: "#/components/schemas/playback-policy" profiles: - $ref: "#/components/schemas/stream/properties/profiles" + type: + - array + - "null" + items: + $ref: "#/components/schemas/ffmpeg-profile" userTags: $ref: "#/components/schemas/stream/properties/userTags" target-add-payload: @@ -1306,7 +1314,9 @@ components: type: boolean description: Decides if the output video should include C2PA signature profiles: - type: array + type: + - array + - "null" items: $ref: "#/components/schemas/transcode-profile" targetSegmentSizeSecs: