v1.6.3/release

- webhooks ask
This commit is contained in:
2020-08-20 12:37:03 -04:00
parent 5a0b008635
commit aa6ff2de41
3 changed files with 117 additions and 5 deletions
+109 -3
View File
@@ -1,9 +1,115 @@
const nodemailer = require('nodemailer');
const Logger = require('../Logger');
const mLogger = new Logger('webhooks', 'ask');
module.exports = async (req, res) => {
mLogger.start();
try {
const { question, answer } = JSON.parse(req.body);
console.info(`[RECEIVED]\tWEBHOOKS/ASK\tQ:${question}\tA:${answer}`);
res.status(200).send({ message: "Got answer." });
mLogger.log('PROGRESS', 'GOT QUESTION ANSWER', { question, answer });
res.status(200).send({ message: 'Got answer.' });
const transporter = nodemailer.createTransport({
host: 'smtp.zoho.com',
port: 465,
secure: true,
auth: {
user: 'admin@chromewatchparty.com',
pass: 'Rpk1kLLDUvMh',
},
});
transporter.verify(async (err, suc) => {
if (err) {
mLogger.error('FAILED TO SETUP EMAIL TRANSPORT', err);
} else {
mLogger.log('PROGRESS', 'SET UP EMAIL TRANSPORT', suc);
await transporter.sendMail({
from: '"⚙ ASK WEBHOOK" <admin@chromewatchparty.com>',
to: 'admin+ask@chromewatchparty.com',
subject: `❔ ${question.substring(0, 17)}...`,
text: `
❓ : ${question}
🅰 : ${answer}
`,
html: `
<style>
* {
font-family: sans-serif;
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
width: 100%;
}
#container {
width: calc(100% - 140px);
background: black;
background-color: black;
padding: 35px 70px;
}
#answer {
background: #c0f300;
background-color: #c0f300;
padding: 30px;
letter-spacing: 1.3px;
}
#container > h5 {
font-size: 18px;
content: 'WATCH PARTY | ASK';
color: #c0f300;
display: block;
margin-bottom: 30px;
font-weight: bold;
letter-spacing: 3px;
}
#question {
background: white;
background-color: white;
padding: 30px;
letter-spacing: 1.3px;
}
#question h5 {
font-size: 18px;
content: 'QUESTION';
font-weight: bolder;
letter-spacing: 2px;
display: block;
margin-bottom: 10px;
}
#answer h5 {
font-size: 18px;
content: 'ANSWER';
font-weight: bolder;
letter-spacing: 2px;
display: block;
margin-bottom: 10px;
}
</style>
<div id="container">
<h5>WATCH PARTY | ASK</h5>
<div id="question">
<h5>QUESTION</h5>
${question}
</div>
<div id="answer">
<h5>ANSWER</h5>
${answer}
</div>
</div>
`,
});
mLogger.success('SENT EMAIL TO ADMIN');
}
});
} catch (e) {
console.info(`[ERROR]\tWEBHOOKS/ASK/Failed To Parse\tBody:${req.body}`);
mLogger.error('FAILED TO PARSE ANSWER', e);
}
};