Skip to content

Commit 843711a

Browse files
committed
fix
1 parent 0d109d3 commit 843711a

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

meteor/server/api/__tests__/peripheralDevice.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import { getCurrentTime } from '../../lib/lib'
1111
import { waitUntil } from '../../../__mocks__/helpers/jest'
1212
import { setupDefaultStudioEnvironment, DefaultEnvironment } from '../../../__mocks__/helpers/database'
1313
import { setLogLevel } from '../../logging'
14-
import {
15-
IngestDeviceSettings,
16-
IngestDeviceSecretSettings,
17-
} from '@sofie-automation/corelib/dist/dataModel/PeripheralDeviceSettings/ingestDevice'
14+
import { IngestDeviceSecretSettings } from '@sofie-automation/corelib/dist/dataModel/PeripheralDeviceSettings/ingestDevice'
1815
import { MediaWorkFlow } from '@sofie-automation/shared-lib/dist/core/model/MediaWorkFlows'
1916
import { MediaWorkFlowStep } from '@sofie-automation/shared-lib/dist/core/model/MediaWorkFlowSteps'
2017
import { MediaManagerAPI } from '@sofie-automation/meteor-lib/dist/api/mediaManager'
@@ -556,7 +553,7 @@ describe('test peripheralDevice general API methods', () => {
556553
expect((deviceWithSecretToken.secretSettings as IngestDeviceSecretSettings).accessToken).toBe(
557554
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
558555
)
559-
expect((deviceWithSecretToken.settings as IngestDeviceSettings).secretAccessToken).toBe(true)
556+
expect(deviceWithSecretToken.secretSettingsStatus?.accessToken).toBe(true)
560557
})
561558

562559
test('uninitialize', async () => {

meteor/server/api/integration/expectedPackages.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
PackageInfos,
3333
} from '../../collections'
3434
import { logger } from '../../logging'
35+
import _ from 'underscore'
3536

3637
export namespace PackageManagerIntegration {
3738
export async function updateExpectedPackageWorkStatuses(
@@ -150,11 +151,11 @@ export namespace PackageManagerIntegration {
150151
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
151152

152153
await ExpectedPackageWorkStatuses.removeAsync({
153-
$or: [
154+
$or: _.compact([
154155
{ deviceId: peripheralDevice._id },
155156
// Since we only have one PM in a studio, we can remove everything in the studio:
156-
{ studioId: peripheralDevice.studioAndConfigId.studioId },
157-
],
157+
peripheralDevice.studioAndConfigId ? { studioId: peripheralDevice.studioAndConfigId.studioId } : null,
158+
]),
158159
})
159160
}
160161

@@ -245,11 +246,11 @@ export namespace PackageManagerIntegration {
245246
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
246247

247248
await PackageContainerPackageStatuses.removeAsync({
248-
$or: [
249+
$or: _.compact([
249250
{ deviceId: peripheralDevice._id },
250251
// Since we only have one PM in a studio, we can remove everything in the studio:
251-
{ studioId: peripheralDevice.studioAndConfigId.studioId },
252-
],
252+
peripheralDevice.studioAndConfigId ? { studioId: peripheralDevice.studioAndConfigId.studioId } : null,
253+
]),
253254
})
254255
}
255256

@@ -332,11 +333,11 @@ export namespace PackageManagerIntegration {
332333
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, deviceToken, context)
333334

334335
await PackageContainerStatuses.removeAsync({
335-
$or: [
336+
$or: _.compact([
336337
{ deviceId: peripheralDevice._id },
337338
// Since we only have one PM in a studio, we can remove everything in the studio:
338-
{ studioId: peripheralDevice.studioAndConfigId.studioId },
339-
],
339+
peripheralDevice.studioAndConfigId ? { studioId: peripheralDevice.studioAndConfigId.studioId } : null,
340+
]),
340341
})
341342
}
342343

meteor/server/migration/X_X_X.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
import { StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
1616
import { literal, unprotectString } from '../lib/tempLib'
1717
import { logger } from '../logging'
18-
import { IngestDeviceSecretSettingsStatus } from '@sofie-automation/corelib/src/dataModel/PeripheralDeviceSettings/ingestDevice'
1918

2019
/*
2120
* **************************************************************************************
@@ -256,13 +255,13 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
256255

257256
for (const device of devices) {
258257
// @ts-expect-error settings is typed as Record<string, any>
259-
const oldSettings = device.settings as IngestDeviceSecretSettingsStatus | undefined
258+
const oldSettings = device.settings as Record<string, any> | undefined
260259

261260
await PeripheralDevices.updateAsync(device._id, {
262261
$set: {
263262
secretSettingsStatus: {
264-
secretCredentials: oldSettings?.secretCredentials,
265-
secretAccessToken: oldSettings?.secretAccessToken,
263+
credentials: oldSettings?.secretCredentials,
264+
accessToken: oldSettings?.secretAccessToken,
266265
},
267266
},
268267
$unset: {

packages/job-worker/src/__mocks__/defaultCollectionObjects.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export function defaultStudio(_id: StudioId): DBStudio {
114114
previewContainerIds: [],
115115
thumbnailContainerIds: [],
116116
peripheralDeviceSettings: {
117+
deviceSettings: wrapDefaultObject({}),
117118
playoutDevices: wrapDefaultObject({}),
118119
ingestDevices: wrapDefaultObject({}),
119120
inputDevices: wrapDefaultObject({}),

0 commit comments

Comments
 (0)