mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Wired up EmailSuppressionList to MEGA
refs https://github.com/TryGhost/Team/issues/2269 This ensures that we do not send emails to members who's email is on the email suppression list
This commit is contained in:
parent
1b526800f0
commit
f056614b45
1 changed files with 9 additions and 2 deletions
|
@ -15,6 +15,7 @@ const db = require('../../data/db');
|
|||
const models = require('../../models');
|
||||
const postEmailSerializer = require('./post-email-serializer');
|
||||
const {getSegmentsFromHtml} = require('./segment-parser');
|
||||
const emailSuppressionList = require('../email-suppression-list');
|
||||
const labs = require('../../../shared/labs');
|
||||
|
||||
// Used to listen to email.added and email.edited model events originally, I think to offload this - ideally would just use jobs now if possible
|
||||
|
@ -560,7 +561,13 @@ async function createEmailBatches({emailModel, memberRows, memberSegment, option
|
|||
|
||||
debug('createEmailBatches: storing recipient list');
|
||||
const startOfRecipientStorage = Date.now();
|
||||
const batches = _.chunk(memberRows, bulkEmailService.BATCH_SIZE);
|
||||
const emails = memberRows.map(row => row.email);
|
||||
const emailSuppressionData = await emailSuppressionList.getBulkSuppressionData(emails);
|
||||
const emailSuppressedLookup = _.zipObject(emails, emailSuppressionData);
|
||||
const filteredRows = memberRows.filter((row) => {
|
||||
return emailSuppressedLookup[row.email].suppressed === false;
|
||||
});
|
||||
const batches = _.chunk(filteredRows, bulkEmailService.BATCH_SIZE);
|
||||
const batchIds = await Promise.mapSeries(batches, storeRecipientBatch);
|
||||
debug(`createEmailBatches: stored recipient list (${Date.now() - startOfRecipientStorage}ms)`);
|
||||
logging.info(`[createEmailBatches] stored recipient list (${Date.now() - startOfRecipientStorage}ms)`);
|
||||
|
|
Loading…
Add table
Reference in a new issue