1
1
import { PeripheralDeviceId , RundownId , RundownPlaylistId } from '@sofie-automation/corelib/dist/dataModel/Ids'
2
2
import { ReadonlyDeep } from 'type-fest'
3
3
import {
4
+ CustomPublish ,
4
5
CustomPublishCollection ,
5
6
meteorCustomPublish ,
6
7
setUpCollectionOptimizedObserver ,
@@ -21,7 +22,8 @@ import { IngestRundownStatus } from '@sofie-automation/shared-lib/dist/ingest/ru
21
22
import { protectString } from '@sofie-automation/corelib/dist/protectedString'
22
23
import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
23
24
import { 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'
25
27
26
28
interface IngestRundownStatusArgs {
27
29
readonly deviceId : PeripheralDeviceId
@@ -171,29 +173,45 @@ async function manipulateIngestRundownStatusPublicationData(
171
173
}
172
174
}
173
175
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
+
174
195
meteorCustomPublish (
175
196
PeripheralDevicePubSub . ingestDeviceRundownStatus ,
176
197
PeripheralDevicePubSubCollectionsNames . ingestRundownStatus ,
177
198
async function ( pub , deviceId : PeripheralDeviceId , token : string | undefined ) {
178
199
check ( deviceId , String )
179
200
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' )
184
214
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 )
198
216
}
199
217
)
0 commit comments