From e0e0a85a32253d603a098e2f590767eb5d3a770c Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Fri, 17 Apr 2020 12:15:26 +0100 Subject: [PATCH] Updated test emails to fetch member data if email matches no issue - with the email replacements feature it's useful to have real member data when sending test emails from the PSM - if the supplied email address matches a member then that member's data will be used for any replacements --- core/server/services/mega/mega.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/server/services/mega/mega.js b/core/server/services/mega/mega.js index 5ad5772df6..6ffd8acf45 100644 --- a/core/server/services/mega/mega.js +++ b/core/server/services/mega/mega.js @@ -93,9 +93,10 @@ const sendEmail = async (postModel, members) => { }; const sendTestEmail = async (postModel, toEmails) => { - const recipients = toEmails.map((email) => { - return {email}; - }); + const recipients = await Promise.all(toEmails.map(async (email) => { + const member = await membersService.api.members.get({email}); + return member || {email}; + })); const {emailTmpl, emails, emailData} = await getEmailData(postModel, recipients); emailTmpl.subject = `[Test] ${emailTmpl.subject}`; return bulkEmailService.send(emailTmpl, emails, emailData);