mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added guard for member rows having missing data when creating email recipients
no issue - we've had an issue with emails failing due to unexpectedly missing data when inserting email recipient rows - added a validation check before adding recipient details along with a log so that invalid data can be investigated
This commit is contained in:
parent
58fda5bad2
commit
82126f29e6
1 changed files with 10 additions and 3 deletions
|
@ -274,8 +274,15 @@ async function createEmailBatches({emailModel, options}) {
|
|||
const knexOptions = _.pick(options, ['transacting', 'forUpdate']);
|
||||
const batchModel = await models.EmailBatch.add({email_id: emailModel.id}, knexOptions);
|
||||
|
||||
const recipientData = recipients.map((memberRow) => {
|
||||
return {
|
||||
const recipientData = [];
|
||||
|
||||
recipients.forEach((memberRow) => {
|
||||
if (!memberRow.id || !memberRow.uuid || !memberRow.email) {
|
||||
logging.warn(`Member row not included as email recipient due to missing data - id: ${memberRow.id}, uuid: ${memberRow.uuid}, email: ${memberRow.email}`);
|
||||
return;
|
||||
}
|
||||
|
||||
recipientData.push({
|
||||
id: ObjectID.generate(),
|
||||
email_id: emailModel.id,
|
||||
member_id: memberRow.id,
|
||||
|
@ -283,7 +290,7 @@ async function createEmailBatches({emailModel, options}) {
|
|||
member_uuid: memberRow.uuid,
|
||||
member_email: memberRow.email,
|
||||
member_name: memberRow.name
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
await db.knex('email_recipients').insert(recipientData);
|
||||
|
|
Loading…
Add table
Reference in a new issue