11import { PeripheralDeviceId , RundownId , RundownPlaylistId } from '@sofie-automation/corelib/dist/dataModel/Ids'
22import { ReadonlyDeep } from 'type-fest'
33import {
4+ CustomPublish ,
45 CustomPublishCollection ,
56 meteorCustomPublish ,
67 setUpCollectionOptimizedObserver ,
@@ -21,7 +22,8 @@ import { IngestRundownStatus } from '@sofie-automation/shared-lib/dist/ingest/ru
2122import { protectString } from '@sofie-automation/corelib/dist/protectedString'
2223import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
2324import { createIngestRundownStatus } from './createIngestRundownStatus'
24- import { Settings } from '../../Settings'
25+ import { assertConnectionHasOneOfPermissions } from '../../security/auth'
26+ import { MeteorPubSub } from '@sofie-automation/meteor-lib/dist/api/pubsub'
2527
2628interface IngestRundownStatusArgs {
2729 readonly deviceId : PeripheralDeviceId
@@ -171,29 +173,45 @@ async function manipulateIngestRundownStatusPublicationData(
171173 }
172174}
173175
176+ async function startOrJoinIngestStatusPublication (
177+ pub : CustomPublish < IngestRundownStatus > ,
178+ deviceId : PeripheralDeviceId
179+ ) {
180+ await setUpCollectionOptimizedObserver <
181+ IngestRundownStatus ,
182+ IngestRundownStatusArgs ,
183+ IngestRundownStatusState ,
184+ IngestRundownStatusUpdateProps
185+ > (
186+ `pub_${ PeripheralDevicePubSub . ingestDeviceRundownStatus } _${ deviceId } ` ,
187+ { deviceId } ,
188+ setupIngestRundownStatusPublicationObservers ,
189+ manipulateIngestRundownStatusPublicationData ,
190+ pub ,
191+ 100
192+ )
193+ }
194+
174195meteorCustomPublish (
175196 PeripheralDevicePubSub . ingestDeviceRundownStatus ,
176197 PeripheralDevicePubSubCollectionsNames . ingestRundownStatus ,
177198 async function ( pub , deviceId : PeripheralDeviceId , token : string | undefined ) {
178199 check ( deviceId , String )
179200
180- if ( Settings . enableHeaderAuth ) {
181- // This is used in a testTool, so only check when auth is enabled
182- await checkAccessAndGetPeripheralDevice ( deviceId , token , this )
183- }
201+ await checkAccessAndGetPeripheralDevice ( deviceId , token , this )
202+
203+ await startOrJoinIngestStatusPublication ( pub , deviceId )
204+ }
205+ )
206+
207+ meteorCustomPublish (
208+ MeteorPubSub . ingestDeviceRundownStatusTestTool ,
209+ PeripheralDevicePubSubCollectionsNames . ingestRundownStatus ,
210+ async function ( pub , deviceId : PeripheralDeviceId ) {
211+ check ( deviceId , String )
212+
213+ assertConnectionHasOneOfPermissions ( this . connection , 'testing' )
184214
185- await setUpCollectionOptimizedObserver <
186- IngestRundownStatus ,
187- IngestRundownStatusArgs ,
188- IngestRundownStatusState ,
189- IngestRundownStatusUpdateProps
190- > (
191- `pub_${ PeripheralDevicePubSub . ingestDeviceRundownStatus } _${ deviceId } ` ,
192- { deviceId } ,
193- setupIngestRundownStatusPublicationObservers ,
194- manipulateIngestRundownStatusPublicationData ,
195- pub ,
196- 100
197- )
215+ await startOrJoinIngestStatusPublication ( pub , deviceId )
198216 }
199217)
0 commit comments