Skip to content

Commit

Permalink
Passed unsubscribeUrl template variable to bulk email
Browse files Browse the repository at this point in the history
no-issue
  • Loading branch information
allouis committed Nov 6, 2019
1 parent 509682c commit 81b9018
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions core/server/services/mega/mega.js
Expand Up @@ -11,11 +11,19 @@ const urlUtils = require('../../lib/url-utils');
const sendEmail = async (post, members) => {
const emailTmpl = postEmailSerializer.serialize(post);

const emails = members.filter((member) => {
const membersToSendTo = members.filter((member) => {
return membersService.contentGating.checkPostAccess(post, member);
}).map(m => m.email);
});
const emails = membersToSendTo.map(member => member.email);
const emailData = membersToSendTo.reduce((emailData, member) => {
return Object.assign({
[member.email]: {
unsubscribe_url: createUnsubscribeUrl(member)
}
}, emailData);
}, {});

return bulkEmailService.send(emailTmpl, emails)
return bulkEmailService.send(emailTmpl, emails, emailData)
.then(() => ({emailTmpl, emails}));
};

Expand Down

0 comments on commit 81b9018

Please sign in to comment.