unlock by discord link option
All checks were successful
Build and push Doorman UI / API / docker (push) Successful in 1m22s
All checks were successful
Build and push Doorman UI / API / docker (push) Successful in 1m22s
This commit is contained in:
parent
641c64989c
commit
76c048b5c9
@ -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,
|
||||
};
|
||||
|
||||
@ -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);
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user