change door polling to use 200 status code and increase graceful timeout time
This commit is contained in:
parent
01fce99766
commit
cb9b011013
@ -37,7 +37,7 @@ exports.handler = async function(context, event, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
response
|
response
|
||||||
.setStatusCode(401)
|
.setStatusCode(200)
|
||||||
.appendHeader('Content-Type', 'application/json')
|
.appendHeader('Content-Type', 'application/json')
|
||||||
.setBody({
|
.setBody({
|
||||||
status: "CLOSED",
|
status: "CLOSED",
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const http = require('http');
|
|||||||
/**
|
/**
|
||||||
* Helper function to do an HTTP request and just await transmission, but not await a response.
|
* Helper function to do an HTTP request and just await transmission, but not await a response.
|
||||||
* ref: https://www.sensedeep.com/blog/posts/stories/lambda-fast-http.html
|
* ref: https://www.sensedeep.com/blog/posts/stories/lambda-fast-http.html
|
||||||
* @param {*} url - the URL to do HTTP request to
|
* @param url - the URL to do HTTP request to
|
||||||
* @returns promise signalling HTTP request has been transmitted
|
* @returns promise signalling HTTP request has been transmitted
|
||||||
*/
|
*/
|
||||||
async function lambdaFastHttp(url) {
|
async function lambdaFastHttp(url) {
|
||||||
@ -102,10 +102,10 @@ exports.handler = async function(context, event, callback) {
|
|||||||
const unlockPromise = new Promise((resolve, reject) => {
|
const unlockPromise = new Promise((resolve, reject) => {
|
||||||
intervals.push(setInterval(() => {
|
intervals.push(setInterval(() => {
|
||||||
fetch(context.DOORMAN_URL + `/api/door/status?door=${config.door}`)
|
fetch(context.DOORMAN_URL + `/api/door/status?door=${config.door}`)
|
||||||
.then(async res => {
|
.then(res => res.json())
|
||||||
if (res.status === 200) {
|
.then(async body => {
|
||||||
|
if (body?.status === "OPEN") {
|
||||||
clearInterval(intervals[0]);
|
clearInterval(intervals[0]);
|
||||||
const body = await res.json();
|
|
||||||
const twiml = new Twilio.twiml.VoiceResponse();
|
const twiml = new Twilio.twiml.VoiceResponse();
|
||||||
doorOpenTwiml(twiml, config);
|
doorOpenTwiml(twiml, config);
|
||||||
if (!discordLock) {
|
if (!discordLock) {
|
||||||
@ -148,7 +148,7 @@ exports.handler = async function(context, event, callback) {
|
|||||||
invokeId, "GracefulFallbackPromise: dropping out of the race, unlock is already notifying discord users"
|
invokeId, "GracefulFallbackPromise: dropping out of the race, unlock is already notifying discord users"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, 6000));
|
}, 8000));
|
||||||
});
|
});
|
||||||
|
|
||||||
const ungracefulFallbackPromise = new Promise((resolve, reject) => {
|
const ungracefulFallbackPromise = new Promise((resolve, reject) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user