[local-sync] Cleanup, use Provider constants

This commit is contained in:
Juan Tejada 2017-01-14 14:31:43 -08:00
parent 941c564443
commit bda6a78ae1
3 changed files with 4 additions and 7 deletions

View file

@ -140,10 +140,6 @@ module.exports = (sequelize, Sequelize) => {
return config;
},
supportsLabels() {
return this.provider === 'gmail'
},
},
});

View file

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

View file

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