diff --git a/packages/doorman-api/functions/api/door/status.js b/packages/doorman-api/functions/api/door/status.js index f087081..f056120 100644 --- a/packages/doorman-api/functions/api/door/status.js +++ b/packages/doorman-api/functions/api/door/status.js @@ -37,7 +37,7 @@ exports.handler = async function(context, event, callback) { } response - .setStatusCode(401) + .setStatusCode(200) .appendHeader('Content-Type', 'application/json') .setBody({ status: "CLOSED", diff --git a/packages/doorman-client/functions/buzzer-activated.js b/packages/doorman-client/functions/buzzer-activated.js index 2f9de26..5ea3a59 100644 --- a/packages/doorman-client/functions/buzzer-activated.js +++ b/packages/doorman-client/functions/buzzer-activated.js @@ -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) => {