From ddbee90c1caf0a407718b9773ad5a9e9211c41e9 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Thu, 11 Aug 2022 08:49:10 +0200 Subject: [PATCH] Fixed bug when checking email batch size - even though we don't do anything yet, the code was calling `.length` on an object, which is `undefined` - this fixes that by checking the length of the keys - also moves the code block down so we can early-return if mailgun is not configured --- ghost/mailgun-client/lib/mailgun-client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ghost/mailgun-client/lib/mailgun-client.js b/ghost/mailgun-client/lib/mailgun-client.js index e9da676d82..7a15ce9a9b 100644 --- a/ghost/mailgun-client/lib/mailgun-client.js +++ b/ghost/mailgun-client/lib/mailgun-client.js @@ -31,16 +31,16 @@ module.exports = class MailgunClient { * } */ send(message, recipientData, replacements) { - if (recipientData.length > module.exports.BATCH_SIZE) { - // err - too many recipients - } - const mailgunInstance = this.getInstance(); if (!mailgunInstance) { logging.warn(`Mailgun is not configured`); return; } + if (Object.keys(recipientData).length > module.exports.BATCH_SIZE) { + // TODO: what to do here? + } + let messageData = {}; try {