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
This commit is contained in:
Daniel Lockyer 2022-08-11 08:49:10 +02:00
parent 5d177c2a11
commit ddbee90c1c
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD

View File

@ -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 {