From b7df5c360d9ab3ac0f41be28d24ba0d5939ef392 Mon Sep 17 00:00:00 2001 From: Rish Date: Wed, 13 Nov 2019 22:53:33 +0530 Subject: [PATCH] Updated send test email to use common email data --- core/server/services/mega/mega.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/server/services/mega/mega.js b/core/server/services/mega/mega.js index 0bb35f1bc4..fbed56b6c3 100644 --- a/core/server/services/mega/mega.js +++ b/core/server/services/mega/mega.js @@ -8,7 +8,7 @@ const models = require('../../models'); const postEmailSerializer = require('./post-email-serializer'); const urlUtils = require('../../lib/url-utils'); -const getEmailData = (post, members) => { +const getEmailData = (post, members = []) => { const emailTmpl = postEmailSerializer.serialize(post); emailTmpl.from = membersService.config.getEmailFromAddress(); @@ -35,9 +35,17 @@ const sendEmail = async (post, members) => { }; const sendTestEmail = async (post, emails) => { - const emailTmpl = postEmailSerializer.serialize(post); + const {emailTmpl} = getEmailData(post); + const emailData = emails.reduce((emailData, email) => { + return Object.assign({ + [email]: { + unique_id: '', + unsubscribe_url: '' + } + }, emailData); + }, {}); emailTmpl.subject = `${emailTmpl.subject} [Test]`; - return bulkEmailService.send(emailTmpl, emails); + return bulkEmailService.send(emailTmpl, emails, emailData); }; /**