mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Moved the filtering of suppressed emails behind a flag check
We want to be able to release this code without restricting the sending of emails on our end, so this logic needs to be behind a feature flag
This commit is contained in:
parent
2350cacf3a
commit
c5b233ac65
1 changed files with 11 additions and 7 deletions
|
@ -563,13 +563,17 @@ async function createEmailBatches({emailModel, memberRows, memberSegment, option
|
|||
|
||||
debug('createEmailBatches: storing recipient list');
|
||||
const startOfRecipientStorage = Date.now();
|
||||
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);
|
||||
let rowsToBatch = memberRows;
|
||||
if (labs.isSet('suppressionList')) {
|
||||
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;
|
||||
});
|
||||
rowsToBatch = filteredRows;
|
||||
}
|
||||
const batches = _.chunk(rowsToBatch, 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