diff --git a/src/coreHandler.ts b/src/coreHandler.ts index 11737ce..086d0d5 100644 --- a/src/coreHandler.ts +++ b/src/coreHandler.ts @@ -101,7 +101,6 @@ export class CoreHandler { } } await this.core.init(ddpConfig) - this.logger.info('Core id: ' + this.core.deviceId) await this.setupObserversAndSubscriptions() this._statusInitialized = true await this.updateCoreStatus() @@ -110,10 +109,9 @@ export class CoreHandler { this.logger.info('Core: Setting up subscriptions..') this.logger.info('DeviceId: ' + this.core.deviceId) await Promise.all([ - this.core.autoSubscribe('peripheralDevices', [this.core.deviceId]), + this.core.autoSubscribe('peripheralDeviceForDevice', this.core.deviceId), this.core.autoSubscribe('studios', [this.core.deviceId]), this.core.autoSubscribe('peripheralDeviceCommands', this.core.deviceId), - // @todo: subscribe to userInput ]) this.logger.info('Core: Subscriptions are set up!') if (this._observers.length) { @@ -124,7 +122,7 @@ export class CoreHandler { this._observers = [] } // setup observers - const observer = this.core.observe('peripheralDevices') + const observer = this.core.observe('peripheralDeviceForDevice') observer.added = (id: string) => { this.onDeviceChanged(protectString(id)) } diff --git a/src/spreadsheetHandler.ts b/src/spreadsheetHandler.ts index 15c0fba..dab709d 100644 --- a/src/spreadsheetHandler.ts +++ b/src/spreadsheetHandler.ts @@ -8,6 +8,7 @@ import { CoreHandler } from './coreHandler' import { RunningOrderWatcher } from './classes/RunningOrderWatcher' import { mutateRundown, mutateSegment, mutatePart } from './mutate' import { PeripheralDeviceForDevice } from '@sofie-automation/server-core-integration' +import { protectString } from '@sofie-automation/shared-lib/dist/lib/protectedString' // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface SpreadsheetConfig { @@ -39,6 +40,7 @@ export interface Credentials { redirect_uris: string[] } } + export interface AccessToken { access_token: string refresh_token: string @@ -47,7 +49,10 @@ export interface AccessToken { expiry_date: number } -const ACCESS_SCOPES = ['https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/spreadsheets'] +const ACCESS_SCOPES = [ + 'https://www.googleapis.com/auth/documents.readonly', + 'https://www.googleapis.com/auth/spreadsheets', +] export class SpreadsheetHandler { public options: SpreadsheetConfig @@ -198,8 +203,9 @@ export class SpreadsheetHandler { this._logger.info('Initializing Spreadsheet connection...') } private getThisPeripheralDevice(): PeripheralDeviceForDevice | undefined { - const peripheralDevices = this._coreHandler.core.getCollection('peripheralDevicesForDevice') - return peripheralDevices.findOne(this._coreHandler.core.deviceId as never) + const peripheralDevices = this._coreHandler.core.getCollection('peripheralDeviceForDevice') + const device = peripheralDevices.findOne(protectString(String(this._coreHandler.core.deviceId))) + return device } private async _updateDevices(): Promise { if (this._disposed) return Promise.resolve()