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