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
This commit is contained in:
Kevin Ansfield 2020-04-17 12:15:26 +01:00
parent d0393b6223
commit e0e0a85a32

View File

@ -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);