output raw fingerprint if we can't deserialize it
All checks were successful
Build and push Doorman UI / API / docker (push) Successful in 1m19s

This commit is contained in:
Martin Dimitrov 2024-10-26 15:30:12 -07:00
parent 5b57024105
commit 016e0cfa85
2 changed files with 8 additions and 4 deletions

View File

@ -7,11 +7,15 @@ exports.handler = async function(context, event, callback) {
let msg = event.msg;
if (event.json && event.json != "undefined") {
const fingerprint = JSON.parse(event.json)?.fingerprint;
try {
const fingerprint = JSON.parse(event.json);
msg += `\`\`\`# Unlocked by\n${JSON.stringify(fingerprint, null, 4)}\`\`\``;
} catch (e) {
msg += `\`\`\`# Unlocked by\n# WARN: Unknown or corrupt raw fingerprint:\n ${fingerprint}\`\`\``;
}
}
console.log(event.msg);
console.log(msg);
// user must be in "Doorman" server
await discord.sendMessageToUser(context,

View File

@ -47,7 +47,7 @@ exports.handler = async function(context, event, callback) {
else if (res.status === 200) {
clearInterval(interval);
const body = await res.json();
twiml.redirect(`/door-open?fingerprint=${encodeURIComponent(JSON.stringify(body))}&${configQuery}`);
twiml.redirect(`/door-open?fingerprint=${encodeURIComponent(JSON.stringify(body.fingerprint))}&${configQuery}`);
callback(null, twiml);
}
})