Skip to content

Commit 3d559f1

Browse files
committed
fix: unable to remove peripheralDevice
1 parent c7bdfe6 commit 3d559f1

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ describe('test peripheralDevice general API methods', () => {
618618
const deviceObj = await PeripheralDevices.findOneAsync(device?._id)
619619
expect(deviceObj).toBeDefined()
620620

621-
await MeteorCall.peripheralDevice.removePeripheralDevice(device._id, device.token)
621+
await MeteorCall.peripheralDevice.removePeripheralDevice(device._id)
622622
}
623623

624624
{

meteor/server/api/peripheralDevice.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import { convertPeripheralDeviceForGateway } from '../publications/peripheralDev
6767
import { executePeripheralDeviceFunction } from './peripheralDevice/executeFunction'
6868
import KoaRouter from '@koa/router'
6969
import bodyParser from 'koa-bodyparser'
70+
import { assertConnectionHasOneOfPermissions } from '../security/auth'
7071

7172
const apmNamespace = 'peripheralDevice'
7273
export namespace ServerPeripheralDeviceAPI {
@@ -513,12 +514,11 @@ export namespace ServerPeripheralDeviceAPI {
513514
},
514515
})
515516
}
516-
export async function removePeripheralDevice(
517-
context: MethodContext,
518-
deviceId: PeripheralDeviceId,
519-
token?: string
520-
): Promise<void> {
521-
const peripheralDevice = await checkAccessAndGetPeripheralDevice(deviceId, token, context)
517+
export async function removePeripheralDevice(context: MethodContext, deviceId: PeripheralDeviceId): Promise<void> {
518+
assertConnectionHasOneOfPermissions(context.connection, 'configure')
519+
520+
const peripheralDevice = await PeripheralDevices.findOneAsync(deviceId)
521+
if (!peripheralDevice) throw new Meteor.Error(404, `PeripheralDevice "${deviceId}" not found`)
522522

523523
logger.info(`Removing PeripheralDevice ${peripheralDevice._id}`)
524524

@@ -850,8 +850,8 @@ class ServerPeripheralDeviceAPIClass extends MethodContextAPI implements NewPeri
850850
async testMethod(deviceId: PeripheralDeviceId, deviceToken: string, returnValue: string, throwError?: boolean) {
851851
return ServerPeripheralDeviceAPI.testMethod(this, deviceId, deviceToken, returnValue, throwError)
852852
}
853-
async removePeripheralDevice(deviceId: PeripheralDeviceId, token?: string) {
854-
return ServerPeripheralDeviceAPI.removePeripheralDevice(this, deviceId, token)
853+
async removePeripheralDevice(deviceId: PeripheralDeviceId) {
854+
return ServerPeripheralDeviceAPI.removePeripheralDevice(this, deviceId)
855855
}
856856

857857
// ------ Playout Gateway --------

packages/shared-lib/src/peripheralDevice/methodsAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export interface NewPeripheralDeviceAPI {
116116
timelineTriggerTime(deviceId: PeripheralDeviceId, deviceToken: string, r: TimelineTriggerTimeResult): Promise<void>
117117
requestUserAuthToken(deviceId: PeripheralDeviceId, deviceToken: string, authUrl: string): Promise<void>
118118
storeAccessToken(deviceId: PeripheralDeviceId, deviceToken: string, authToken: string): Promise<void>
119-
removePeripheralDevice(deviceId: PeripheralDeviceId, deviceToken?: string): Promise<void>
119+
removePeripheralDevice(deviceId: PeripheralDeviceId): Promise<void>
120120
reportResolveDone(
121121
deviceId: PeripheralDeviceId,
122122
deviceToken: string,

0 commit comments

Comments
 (0)