Add html-minifier for outgoing email
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
4f4d84474c
commit
ca690c7a7e
@ -2,6 +2,7 @@ const log = require('../utils/log.utils');
|
||||
const crypto = require('crypto')
|
||||
const db = require('../services/dbAccess.services');
|
||||
const fs = require('fs/promises')
|
||||
const minify = require('html-minifier').minify;
|
||||
|
||||
// Checks users registration key against issued keys
|
||||
async function isAuthed(uuid) { // Needs testing
|
||||
@ -32,13 +33,16 @@ async function generateKey() { // Needs testing & moving to 'register.utils'
|
||||
|
||||
async function generateConfirmationEmail(eml, uuid) {
|
||||
try {
|
||||
let htmlTpl = fs.readFile('mail-templates/register.html', 'utf-8');
|
||||
let htmlTpl = await fs.readFile('mail-templates/register.html', 'utf-8');
|
||||
let minify = await minify(((htmlTpl).replace(/>>ACCESSCODE<</g, uuid)), {
|
||||
removeComments: true
|
||||
});
|
||||
let txtTpl = fs.readFile('mail-templates/register.txt', 'utf-8');
|
||||
return msg = {
|
||||
to: eml,
|
||||
subject: "OwlBoard Registration",
|
||||
text: (await txtTpl).replace(/>>ACCESSCODE<</g, uuid),
|
||||
html: (await htmlTpl).replace(/>>ACCESSCODE<</g, uuid)
|
||||
html: minify
|
||||
}
|
||||
} catch(err) {
|
||||
log.out(`mailServices.generateConfirmationEmail: Error reading templates, $(err)`, "err");
|
||||
|
Loading…
Reference in New Issue
Block a user