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

View File

@ -20,7 +20,21 @@ export const createDynaBridgeClient = (context: TwilioContext) => {
return new DynaBridge({
doorConfig: DoorConfigEntity,
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" ,
credentials: {
accessKeyId: context.AWS_ACCESS_KEY,