diff --git a/src/tv2-common/getSegment.ts b/src/tv2-common/getSegment.ts index a5cbdd94..a9dbc78b 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,24 @@ 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 + const doesSegmentHaveValidParts: boolean = parts.length > 0 && parts.some((part) => part.pieces.length > 0) + if (doesSegmentHaveMiniShelf && doesSegmentHaveValidParts) { + return { + reason: 'MiniShelf Segments are not allowed to also have Parts.' + } + } + return undefined +}