0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Filtered out members which are unsubscribed in mailing service

This commit is contained in:
Nazar Gargol 2019-11-05 16:21:10 +07:00 committed by Fabien O'Carroll
parent 1ef015da10
commit d0bf6e8579

View file

@ -8,12 +8,14 @@ const postEmailSerializer = require('./post-email-serializer');
const sendEmail = async (post) => {
const emailTmpl = postEmailSerializer.serialize(post);
const {members} = await membersService.api.members.list({limit: 'all'});
const {members} = await membersService.api.members.list(Object.assign({filter: 'subscribed:true'}, {limit: 'all'}));
const emails = members.filter((member) => {
return membersService.contentGating.checkPostAccess(post, member);
}).map(m => m.email);
return bulkEmailService.send(emailTmpl, emails);
if (members.length) {
return bulkEmailService.send(emailTmpl, emails);
}
};
const sendTestEmail = async (post, emails) => {