// Metro module 13528 (f13529). import * as _Constants from "../../Constants"; import { RPCErrors, RPCCommands } from "../../../../Constants"; import { DeviceTypes } from "../../../../_bundle/Module4250"; import { OAuth2Scopes } from "../../../../_bundle/Module8174"; import createRpcJoiSchemaObject from "../../helpers/createRpcJoiSchemaObject"; import RPCError from "../../RPCError"; import { setCertifiedDevices } from "../../../../actions/CertifiedDeviceActionCreators"; const { RPC_LOCAL_SCOPE, RPC_SCOPE_CONFIG } = _Constants; const r25 = {}; const SET_CERTIFIED_DEVICES = RPCCommands.SET_CERTIFIED_DEVICES; const scope = {}; scope[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, RPC_LOCAL_SCOPE]; r25[SET_CERTIFIED_DEVICES] = { scope, validation: (a0) => createRpcJoiSchemaObject(a0).required().keys({ devices: a0.array().items(createRpcJoiSchemaObject(a0).keys({ type: a0.string().required().valid([DeviceTypes.AUDIO_INPUT, DeviceTypes.AUDIO_OUTPUT, DeviceTypes.VIDEO_INPUT]), id: a0.string().required().min(1), vendor: createRpcJoiSchemaObject(a0).required().keys({ name: a0.string().min(1), url: a0.string().min(1) }), model: createRpcJoiSchemaObject(a0).required().keys({ name: a0.string().min(1), url: a0.string().min(1) }), related: a0.array().items(a0.string().min(1)), echo_cancellation: a0.boolean(), noise_suppression: a0.boolean(), automatic_gain_control: a0.boolean(), hardware_mute: a0.boolean() })) }), handler: (a0) => { const socket = a0.socket; const devices = a0.args.devices; if (socket.application.id == null) { throw new RPCError({ errorCode: RPCErrors.INVALID_COMMAND }, "No application."); } setCertifiedDevices(socket.application.id, devices.map((device) => ({ type: device.type, id: device.id, vendor: device.vendor, model: device.model, related: device.related.filter((c30635_0) => devices.some((device) => device.id === c30635_0)), echoCancellation: device.echo_cancellation, noiseSuppression: device.noise_suppression, automaticGainControl: device.automatic_gain_control, hardwareMute: device.hardware_mute }))); } }; export default r25;