-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae67689
commit fd569a8
Showing
1 changed file
with
8 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import PageController from './pageController.js' | ||
import yaml from 'js-yaml'; | ||
import fs from 'fs'; | ||
import yaml from 'js-yaml' | ||
import fs from 'fs' | ||
|
||
const templateFile = 'src/assets/emailTemplates/newEndpoint.yml' | ||
|
||
const templateContent = fs.readFileSync(templateFile, 'utf8'); | ||
const template = yaml.load(templateContent); | ||
const templateContent = fs.readFileSync(templateFile, 'utf8') | ||
const template = yaml.load(templateContent) | ||
|
||
class confirmationController extends PageController { | ||
locals(req, res, next) { | ||
locals (req, res, next) { | ||
const name = req.sessionModel.get('name') | ||
const email = req.sessionModel.get('email') | ||
const organisation = req.sessionModel.get('lpa') | ||
|
@@ -17,9 +17,9 @@ class confirmationController extends PageController { | |
const endpoint = req.sessionModel.get('endpoint-url') | ||
|
||
const recipient = '[email protected]' | ||
const templateVars = { name, organisation, email, endpoint, documentationUrl, dataset }; | ||
const subject = template.subject.replace(/\${(.*?)}/g, (match, key) => templateVars[key]); | ||
const body = template.body.replace(/\${(.*?)}/g, (match, key) => templateVars[key]); | ||
const templateVars = { name, organisation, email, endpoint, documentationUrl, dataset } | ||
const subject = template.subject.replace(/\${(.*?)}/g, (match, key) => templateVars[key]) | ||
const body = template.body.replace(/\${(.*?)}/g, (match, key) => templateVars[key]) | ||
|
||
req.form.options.mailTo = `mailto:${recipient}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}` | ||
|
||
|