From 96685bed01a40a92d255ec4e7c9c528f1ea24f7a Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Fri, 31 Mar 2017 16:13:52 -0700 Subject: [PATCH] [client-app] don't override existing bodies on K2 Summary: Bodies that already exist on K2 shouldn't be overridden. See the comment for how this caused open/link tracking to fail in certain cases when a lot of messages were being sent Test Plan: manual Reviewers: halla, mark, spang, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D4319 --- .../worker-ui/lib/developer-bar.cjsx | 3 ++- .../client-sync/src/message-processor/index.js | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/client-app/internal_packages/worker-ui/lib/developer-bar.cjsx b/packages/client-app/internal_packages/worker-ui/lib/developer-bar.cjsx index d2e9c7cd2..4ed966562 100644 --- a/packages/client-app/internal_packages/worker-ui/lib/developer-bar.cjsx +++ b/packages/client-app/internal_packages/worker-ui/lib/developer-bar.cjsx @@ -5,6 +5,7 @@ React = require 'react' TaskQueue, Actions, Contact, + Utils, Message} = require 'nylas-exports' {InjectedComponentSet} = require 'nylas-component-kit' @@ -153,7 +154,7 @@ class DeveloperBar extends React.Component @setState(section: section) _getStateFromStores: => - queue: TaskQueue._queue + queue: Utils.deepClone(TaskQueue._queue) completed: TaskQueue._completed curlHistory: DeveloperBarStore.curlHistory() longPollHistory: DeveloperBarStore.longPollHistory() diff --git a/packages/client-sync/src/message-processor/index.js b/packages/client-sync/src/message-processor/index.js index 5791aa6cd..925bbac98 100644 --- a/packages/client-sync/src/message-processor/index.js +++ b/packages/client-sync/src/message-processor/index.js @@ -274,7 +274,21 @@ class MessageProcessor { async _processExistingMessage({existingMessage, messageValues, struct} = {}) { const {accountId} = messageValues; const db = await LocalDatabaseConnector.forAccount(accountId); - await existingMessage.update(messageValues); + + /** + * There should never be a reason to update the body of a message + * already in the database. + * + * When we use link/open tracking on Gmail, we optimistically create a + * Message whose body is stripped of tracking pixels (so you don't + * self trigger). Since it takes time to delete the old draft on Gmail + * & restuff, it's possible to sync a message with a non-stripped body + * (which would cause you to self-trigger)). This prevents this from + * happening. + */ + const newMessageWithoutBody = _.clone(messageValues) + delete newMessageWithoutBody.body; + await existingMessage.update(newMessageWithoutBody); if (messageValues.labels && messageValues.labels.length > 0) { await existingMessage.setLabels(messageValues.labels) }