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
+6 -1
View File
@@ -1,6 +1,6 @@
{
"name": "watch-party-api",
"version": "1.6.2",
"version": "1.6.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -1894,6 +1894,11 @@
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.1.tgz",
"integrity": "sha512-G6RlQt5Sb4GMBzXvhfkeFmbqR6MzhtnT7VTHuLadjkii3rdYHNdw0m8zA4BTxVIh68FicCQ2NSUANpsqkr9jvQ=="
},
"nodemailer": {
"version": "6.4.11",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.11.tgz",
"integrity": "sha512-BVZBDi+aJV4O38rxsUh164Dk1NCqgh6Cm0rQSb9SK/DHGll/DrCMnycVDD7msJgZCnmVa8ASo8EZzR7jsgTukQ=="
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+2 -1
View File
@@ -18,7 +18,8 @@
"express": "^4.17.1",
"firebase-admin": "^9.0.0",
"firebase-functions": "^3.3.0",
"node-fetch": "^2.6.0"
"node-fetch": "^2.6.0",
"nodemailer": "^6.4.11"
},
"devDependencies": {
"eslint": "^5.12.0",
+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);
}
};