unlock by discord link option
All checks were successful
Build and push Doorman UI / API / docker (push) Successful in 1m22s

This commit is contained in:
Martin Dimitrov 2024-10-26 14:37:14 -07:00
parent 641c64989c
commit 76c048b5c9
2 changed files with 20 additions and 4 deletions

View File

@ -25,14 +25,25 @@ exports.handler = async function(context, event, callback) {
}
let correctPin = config.Item.pin.S;
let discordUsers = config.Item.discordUsers.SS;
if (correctPin !== pin) {
let method;
if (correctPin === pin) {
method = "PIN";
}
if (discordUsers.includes(pin)) {
method = "DISCORD";
}
if (!method) {
response.setStatusCode(401);
return callback(null, response);
}
const fingerprint = {
method: "PIN",
method,
userAgent: event.request.headers['user-agent'],
ip: event.ip,
};

View File

@ -25,6 +25,13 @@ exports.handler = async function(context, event, callback) {
let configQuery = `config=${encodeURIComponent(JSON.stringify(config))}`;
// let user know someone is currently buzzing, and allow unlock by discord user
let msg = `🔔 Someone is dialing right now @ Door "${config.door}" [Click to unlock](${context.DOORMAN_URL}/api/door/auth?door=buzzer&key=`;
config.discordUsers.forEach((u) => {
// unlock me by discord userid
fetch(context.DOORMAN_URL + `/api/door/notify?discordUser=${u}&msg=${encodeURIComponent(msg + u + ')')}`);
});
// poll Doorman, to see if we should unlock
const interval = setInterval(() => {
fetch(context.DOORMAN_URL + `/api/door/status?door=${config.door}`)
@ -52,6 +59,4 @@ exports.handler = async function(context, event, callback) {
twiml.redirect(`/call-residents?${configQuery}`);
callback(null, twiml);
}, 6000);
// return callback(null, twiml);
};