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
|
||||
.setStatusCode(401)
|
||||
.setStatusCode(200)
|
||||
.appendHeader('Content-Type', 'application/json')
|
||||
.setBody({
|
||||
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.
|
||||
* 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
|
||||
*/
|
||||
async function lambdaFastHttp(url) {
|
||||
@ -102,10 +102,10 @@ exports.handler = async function(context, event, callback) {
|
||||
const unlockPromise = new Promise((resolve, reject) => {
|
||||
intervals.push(setInterval(() => {
|
||||
fetch(context.DOORMAN_URL + `/api/door/status?door=${config.door}`)
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
.then(res => res.json())
|
||||
.then(async body => {
|
||||
if (body?.status === "OPEN") {
|
||||
clearInterval(intervals[0]);
|
||||
const body = await res.json();
|
||||
const twiml = new Twilio.twiml.VoiceResponse();
|
||||
doorOpenTwiml(twiml, config);
|
||||
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"
|
||||
);
|
||||
}
|
||||
}, 6000));
|
||||
}, 8000));
|
||||
});
|
||||
|
||||
const ungracefulFallbackPromise = new Promise((resolve, reject) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user