From 7f9fe5b387ac8693cf679f309fe27bf5d82edc7c Mon Sep 17 00:00:00 2001 From: Rasmus Lindved Date: Tue, 14 May 2024 09:04:49 +0200 Subject: [PATCH] SOF-1979 Add 'invalidity' field to Segment --- src/tv2-common/getSegment.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/tv2-common/getSegment.ts b/src/tv2-common/getSegment.ts index a5cbdd94..9590ab3f 100644 --- a/src/tv2-common/getSegment.ts +++ b/src/tv2-common/getSegment.ts @@ -84,6 +84,14 @@ export interface GetSegmentShowstyleOptions BlueprintResultPart | Promise } +interface Segment extends IBlueprintSegment { + invalidity?: SegmentInvalidity +} + +interface SegmentInvalidity { + reason: string +} + interface SegmentMetadata { miniShelfVideoClipFile?: string } @@ -97,7 +105,7 @@ export async function getSegmentBase const segmentPayload = ingestSegment.payload as INewsPayload | undefined const iNewsStory = segmentPayload?.iNewsStory - const segment: IBlueprintSegment = { + const segment: Segment = { name: ingestSegment.name || '', metaData: {}, showShelf: false, @@ -385,8 +393,23 @@ export async function getSegmentBase } }) + segment.invalidity = getSegmentInvalidity(segment, blueprintParts) + return { segment, parts: blueprintParts } } + +function getSegmentInvalidity( + segment: Segment, + parts: BlueprintResultPart[] +): SegmentInvalidity | undefined { + const doesSegmentHaveMiniShelf: boolean = !!segment.metaData?.miniShelfVideoClipFile + if (doesSegmentHaveMiniShelf && parts.length > 0) { + return { + reason: 'MiniShelf Segments are not allowed to also have Parts.' + } + } + return undefined +}