Skip to content

Commit 351f223

Browse files
Merge branch 'master' into snyk-upgrade-8e33556e94037e848c3538599c66fb37
2 parents fba939b + 701b2f9 commit 351f223

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/email/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,18 @@ const sendForgotPassword = async (userEmail, resetPasswordToken) => {
5555
}
5656
}
5757

58-
const sendContactCheckInEmail = async (info) => {
58+
const sendContactCheckInEmail = async (info, origin) => {
59+
const url = origin ? origin : process.env.VUE_APP_URL
5960
try {
60-
const entityLink = `${process.env.URL}/checkin/${info.entityId}?token=${info.token}`
61+
const entityLink = `${url}/checkin/${info.entityId}?token=${info.token}`
6162
const emailTitle = `${info.entityName} Healthcare Rollcall Check In`
6263
const emailContents = `Hello ${info.name}! It is time to update the status of ${info.entityName}. Please click the link below to check in.`
6364
const template = (info.entityType === 'Assisted Living Facility') ? 'assisted_living_checkin' : 'contact_check_in'
6465
await sendMail(
6566
info.email,
6667
emailTitle,
67-
nunjucks.render(`${template}_html.njk`, { emailTitle, emailContents, entityLink }),
68-
nunjucks.render(`${template}_text.njk`, { emailTitle, emailContents, entityLink })
68+
nunjucks.render(`${template}_html.njk`, {emailTitle, emailContents, entityLink}),
69+
nunjucks.render(`${template}_text.njk`, {emailTitle, emailContents, entityLink})
6970
)
7071

7172
return true
@@ -74,4 +75,4 @@ const sendContactCheckInEmail = async (info) => {
7475
}
7576
}
7677

77-
export default {sendForgotPassword, sendContactCheckInEmail}
78+
export default {sendForgotPassword, sendContactCheckInEmail, sendMail}

src/routes/contact.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ router.post('/send', async (req, res) => {
212212
}
213213

214214
emails.forEach(async (e) => {
215-
email.sendContactCheckInEmail(e)
215+
email.sendContactCheckInEmail(e, req.headers.origin)
216216
})
217217

218218
const uniqueEntities = [...new Set(emails.map(email => email.entityId))]
@@ -239,6 +239,7 @@ router.post('/send/:type/:id', async (req, res) => {
239239

240240
try {
241241
let entity
242+
242243
if (req.params.type.toLowerCase() === 'entity') {
243244
entity = await models.Entity.findById(req.params.id)
244245
} else if (req.params.type.toLowerCase() === 'contact') {
@@ -261,7 +262,7 @@ router.post('/send/:type/:id', async (req, res) => {
261262
entityId: entity.id,
262263
token: temporaryToken
263264
}
264-
email.sendContactCheckInEmail(e).then(() => {
265+
email.sendContactCheckInEmail(e, req.headers.origin).then(() => {
265266
response.setMessage(`${entity.name} emailed sent.`)
266267
response.setCode(200)
267268
}, err => {

0 commit comments

Comments
 (0)