fix deserialiation
All checks were successful
Build and push Doorman UI / API / docker (push) Successful in 1m30s
Build and push image for doorman-homeassistant / docker (push) Successful in 51s
Build and push image for doorman-homeassistant / deploy-gitainer (push) Successful in 5s

This commit is contained in:
Martin Dimitrov 2025-05-31 14:17:33 -07:00
parent 446942582c
commit 73e98c0508
2 changed files with 22 additions and 10 deletions

View File

@ -79,9 +79,7 @@ export const handler: ServerlessFunctionSignature<TwilioContext, InfoRequest> =
} else { } else {
await client.send(getLockStatusCommand(door)) await client.send(getLockStatusCommand(door))
.then(async (lock) => { .then(async (lock) => {
const config = await client.send(getDoorConfigCommand(door));
const status = isLockOpen(lock) ? DoorStatus.OPEN: DoorStatus.CLOSED; const status = isLockOpen(lock) ? DoorStatus.OPEN: DoorStatus.CLOSED;
const doorConfig: DoorConfig = ddbItemToJSON<DoorConfig>(config);
// respond to UI // respond to UI
response response
@ -89,14 +87,14 @@ export const handler: ServerlessFunctionSignature<TwilioContext, InfoRequest> =
.appendHeader('Content-Type', 'application/json') .appendHeader('Content-Type', 'application/json')
.setBody({ .setBody({
id: door, id: door,
timeout: doorConfig.timeout, timeout: config.timeout,
buzzer: doorConfig.buzzer, buzzer: config.buzzer,
status, status,
buzzerCode: doorConfig.buzzerCode, buzzerCode: config.buzzerCode,
fallbackNumbers: doorConfig.fallbackNumbers, fallbackNumbers: config.fallbackNumbers,
pressKey: doorConfig.pressKey, pressKey: config.pressKey,
discordUsers: doorConfig.discordUsers || [], discordUsers: config.discordUsers || [],
greeting: doorConfig.greeting || "", greeting: config.greeting || "",
}); });
}).catch((e) => { }).catch((e) => {

View File

@ -20,7 +20,21 @@ export const createDynaBridgeClient = (context: TwilioContext) => {
return new DynaBridge({ return new DynaBridge({
doorConfig: DoorConfigEntity, doorConfig: DoorConfigEntity,
editDoorConfig: EditDoorConfigEntity, editDoorConfig: EditDoorConfigEntity,
}, undefined, { }, {
serialize: (entity) => entity,
deserialize: (entity) => {
// convert all set to array
const convertedObj = Object.fromEntries(
Object.entries(entity).map(([key, value]) => {
if (value instanceof Set) {
return [key, Array.from(value)];
}
return [key, value];
})
);
return convertedObj;
}
}, {
region: "us-east-1" , region: "us-east-1" ,
credentials: { credentials: {
accessKeyId: context.AWS_ACCESS_KEY, accessKeyId: context.AWS_ACCESS_KEY,