fix deserialiation
This commit is contained in:
parent
446942582c
commit
73e98c0508
@ -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) => {
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user