Martin Dimitrov 016e0cfa85
All checks were successful
Build and push Doorman UI / API / docker (push) Successful in 1m19s
output raw fingerprint if we can't deserialize it
2024-10-26 15:30:12 -07:00

28 lines
773 B
JavaScript

exports.handler = async function(context, event, callback) {
const response = new Twilio.Response();
const discordPath = Runtime.getFunctions()['common/discord'].path;
const discord = require(discordPath);
let msg = event.msg;
if (event.json && event.json != "undefined") {
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(msg);
// user must be in "Doorman" server
await discord.sendMessageToUser(context,
event.discordUser,
msg,
).catch((e) => console.error(e));
return callback(null, response);
};