mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 07:34:54 +00:00
Refactor SceneService to update device uuid in actions
This commit is contained in:
@ -241,12 +241,30 @@ export class SceneService {
|
||||
throw new HttpException(response.msg, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const responseData = convertKeysToCamelCase(response.result);
|
||||
const actions = responseData.actions.map((action) => {
|
||||
return {
|
||||
...action,
|
||||
};
|
||||
});
|
||||
|
||||
for (const action of actions) {
|
||||
if (action.actionExecutor === 'device_issue') {
|
||||
const device = await this.deviceService.getDeviceByDeviceTuyaUuid(
|
||||
action.entityId,
|
||||
);
|
||||
|
||||
if (device) {
|
||||
action.entityId = device.uuid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
id: responseData.id,
|
||||
name: responseData.name,
|
||||
status: responseData.status,
|
||||
type: 'tap_to_run',
|
||||
actions: responseData.actions,
|
||||
actions: actions,
|
||||
...(withSpaceId && { spaceId: responseData.spaceId }),
|
||||
};
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user