From bda6a78ae1c39a3ed094456ad16bdc3424aa7610 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Sat, 14 Jan 2017 14:31:43 -0800 Subject: [PATCH] [local-sync] Cleanup, use Provider constants --- packages/isomorphic-core/src/models/account.js | 4 ---- packages/local-sync/src/local-api/routes/messages.js | 3 ++- .../syncback-tasks/ensure-message-in-sent-folder.imap.js | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/isomorphic-core/src/models/account.js b/packages/isomorphic-core/src/models/account.js index 709d9534b..b129ac297 100644 --- a/packages/isomorphic-core/src/models/account.js +++ b/packages/isomorphic-core/src/models/account.js @@ -140,10 +140,6 @@ module.exports = (sequelize, Sequelize) => { return config; }, - - supportsLabels() { - return this.provider === 'gmail' - }, }, }); diff --git a/packages/local-sync/src/local-api/routes/messages.js b/packages/local-sync/src/local-api/routes/messages.js index 4366b0979..db93ec5a4 100644 --- a/packages/local-sync/src/local-api/routes/messages.js +++ b/packages/local-sync/src/local-api/routes/messages.js @@ -1,4 +1,5 @@ const Joi = require('joi'); +const {Provider} = require('isomorphic-core') const Serialization = require('../serialization'); const {createAndReplyWithSyncbackRequest} = require('../route-helpers'); @@ -118,7 +119,7 @@ module.exports = (server) => { const payload = request.payload if (payload.label_ids || payload.labels) { const account = request.auth.credentials; - if (account.supportsLabels()) { + if (account.provider === Provider.Gmail) { createAndReplyWithSyncbackRequest(request, reply, { type: "SetMessageLabels", props: { diff --git a/packages/local-sync/src/local-sync-worker/syncback-tasks/ensure-message-in-sent-folder.imap.js b/packages/local-sync/src/local-sync-worker/syncback-tasks/ensure-message-in-sent-folder.imap.js index 1a8c67ab2..1e6c70a27 100644 --- a/packages/local-sync/src/local-sync-worker/syncback-tasks/ensure-message-in-sent-folder.imap.js +++ b/packages/local-sync/src/local-sync-worker/syncback-tasks/ensure-message-in-sent-folder.imap.js @@ -1,4 +1,4 @@ -const {SendmailClient, Errors: {APIError}} = require('isomorphic-core') +const {SendmailClient, Provider, Errors: {APIError}} = require('isomorphic-core') const IMAPHelpers = require('../imap-helpers') const SyncbackTask = require('./syncback-task') @@ -48,7 +48,7 @@ class EnsureMessageInSentFolderIMAP extends SyncbackTask { // Each participant gets a message, but all of those messages have the // same Message-ID header in them. This allows us to find all of the // sent messages and clean them up - if (sentPerRecipient && provider === 'gmail') { + if (sentPerRecipient && provider === Provider.Gmail) { try { await IMAPHelpers.deleteGmailSentMessages({db, imap, provider, headerMessageId}) } catch (err) {