From 1e0ae4fb03021a4790465e8bc2b6d64f6a477bd9 Mon Sep 17 00:00:00 2001 From: Halla Moore Date: Thu, 16 Feb 2017 16:10:49 -0800 Subject: [PATCH] [cloud-core, cloud-workers, isomorphic-core] Fix sending from cloud-workers Summary: The SendmailClient is in isomorphic-core, but wasn't working properly when called from cloud-workers. This diff includes a variety of fixes to get it working: - Add smtp config to connection settings in cloud-core - Don't use `PromiseUtils.promisify` for a function that needs `this` to be bound properly - Don't reference `NylasEnv` (That error gets caught and reported elsewhere anyway, we don't need to report it here) - Default `message.uploads` to `[]` to keep iterator happy - Add Gmail environment variables to cloud-worker app Test Plan: manual Reviewers: juan, khamidou, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D3954 --- packages/isomorphic-core/src/sendmail-client.es6 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/isomorphic-core/src/sendmail-client.es6 b/packages/isomorphic-core/src/sendmail-client.es6 index 0fc5f0806..6d317cc4c 100644 --- a/packages/isomorphic-core/src/sendmail-client.es6 +++ b/packages/isomorphic-core/src/sendmail-client.es6 @@ -60,7 +60,6 @@ class SendmailClient { throw new APIError('Sending failed - Network Error', 401, {originalError: error}) } - NylasEnv.reportError(error) throw new APIError('Sending failed', 500, {originalError: error}); } @@ -77,7 +76,8 @@ class SendmailClient { msgData.messageId = message.headerMessageId; msgData.attachments = [] - for (const upload of message.uploads) { + const uploads = message.uploads || [] + for (const upload of uploads) { msgData.attachments.push({ filename: upload.filename, content: fs.createReadStream(upload.targetPath),