pis #12
@ -75,7 +75,7 @@ async function delRegReq(uuid) {
|
||||
|
||||
module.exports = {
|
||||
query,
|
||||
increment, // Probqbly doesn't need exporting?
|
||||
//increment, // Probqbly doesn't need exporting?
|
||||
addUser,
|
||||
userAtime,
|
||||
addRegReq,
|
||||
|
@ -2,7 +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
|
||||
const minify = require('../utils/minify.utils')
|
||||
|
||||
// Checks users registration key against issued keys
|
||||
async function isAuthed(uuid) { // Needs testing
|
||||
@ -33,18 +33,15 @@ async function generateKey() { // Needs testing & moving to 'register.utils'
|
||||
|
||||
async function generateConfirmationEmail(eml, uuid) {
|
||||
try {
|
||||
let htmlTpl = await fs.readFile('mail-templates/register.html', 'utf-8')
|
||||
let mini = minify(((htmlTpl).replace(/>>ACCESSCODE<</g, uuid)), { // Add collapse whitespace here
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
minifyCSS: true
|
||||
})
|
||||
let txtTpl = fs.readFile('mail-templates/register.txt', 'utf-8')
|
||||
return { // CSS Needs to be inlined. See css-inline, or css-inliner
|
||||
const htmlTpl = await fs.readFile('mail-templates/register.html', 'utf-8')
|
||||
const htmlStr = htmlTpl.replace(/>>ACCESSCODE<</g, uuid)
|
||||
const htmlMin = await minify(htmlStr)
|
||||
const txtTpl = fs.readFile('mail-templates/register.txt', 'utf-8')
|
||||
return {
|
||||
to: eml,
|
||||
subject: 'OwlBoard Registration',
|
||||
text: (await txtTpl).replace(/>>ACCESSCODE<</g, uuid),
|
||||
html: mini
|
||||
html: htmlMin
|
||||
}
|
||||
} catch(err) {
|
||||
log.out('mailServices.generateConfirmationEmail: Error reading templates, $(err)', 'err')
|
||||
|
@ -1,7 +1,10 @@
|
||||
const htmlShrink = require('html-minifier').minify
|
||||
const juice = require('juice')
|
||||
|
||||
module.exports = async function minifyMail(input) {
|
||||
// Minify HTML input, including inline styles.
|
||||
//let inline = cssInliner(input) ??
|
||||
return htmlShrink(input)
|
||||
const inlined = juice(input)
|
||||
return htmlShrink(inlined, {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user