diff --git a/packages/nylas-core/models/account/message.js b/packages/nylas-core/models/account/message.js index 4cacb1f5a..3b7791436 100644 --- a/packages/nylas-core/models/account/message.js +++ b/packages/nylas-core/models/account/message.js @@ -8,7 +8,7 @@ module.exports = (sequelize, Sequelize) => { const Message = sequelize.define('message', { accountId: { type: Sequelize.STRING, allowNull: false }, version: Sequelize.INTEGER, - messageId: Sequelize.STRING, + headerMessageId: Sequelize.STRING, body: Sequelize.STRING, headers: JSONType('headers'), subject: Sequelize.STRING, @@ -23,7 +23,7 @@ module.exports = (sequelize, Sequelize) => { cc: JSONARRAYType('cc'), bcc: JSONARRAYType('bcc'), replyTo: JSONARRAYType('replyTo'), - categoryUID: { type: Sequelize.STRING, allowNull: true}, + categoryImapUID: { type: Sequelize.STRING, allowNull: true}, }, { indexes: [ { @@ -50,7 +50,7 @@ module.exports = (sequelize, Sequelize) => { }) .then(({category, connection}) => { return connection.openBox(category.name) - .then((imapBox) => imapBox.fetchMessage(this.categoryUID)) + .then((imapBox) => imapBox.fetchMessage(this.categoryImapUID)) .then((message) => { if (message) { return Promise.resolve(`${message.headers}${message.body}`) diff --git a/packages/nylas-message-processor/spec/fixtures/thread.js b/packages/nylas-message-processor/spec/fixtures/thread.js index cf4f9768a..ce407afb7 100644 --- a/packages/nylas-message-processor/spec/fixtures/thread.js +++ b/packages/nylas-message-processor/spec/fixtures/thread.js @@ -57,7 +57,7 @@ export const message = { }], cc: [], bcc: [], - messageId: "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>", + headerMessageId: "<82y7eq1ipmadaxwcy6kr072bw-2147483647@mailer.nylas.com>", snippet: "Hi Jackie, While browsing Nylas themes, I stumbled upon your website and looked at your work. Great ", setThread: (thread) => { message.thread = thread.id @@ -86,7 +86,7 @@ export const reply = { }], cc: [], bcc: [], - messageId: "", + headerMessageId: "", snippet: "Sagar, Aw, glad to hear it! Thanks for getting in touch! Jackie Luo Software Engineer, Nylas", setThread: (thread) => { reply.thread = thread.id diff --git a/packages/nylas-message-processor/spec/parsing-spec.js b/packages/nylas-message-processor/spec/parsing-spec.js index 64b6504f6..e8025c0b7 100644 --- a/packages/nylas-message-processor/spec/parsing-spec.js +++ b/packages/nylas-message-processor/spec/parsing-spec.js @@ -15,7 +15,7 @@ it('parses the message correctly', (done) => { processMessage({message}).then((processed) => { expect(processed.headers['in-reply-to']).toEqual('') - expect(processed.messageId).toEqual('') + expect(processed.headerMessageId).toEqual('') expect(processed.subject).toEqual('Re: [electron/electron.atom.io] Add Jasper app (#352)') expect(processed.body.includes(bodyPart)).toBe(true) done() diff --git a/packages/nylas-sync/imap/fetch-messages-in-category.js b/packages/nylas-sync/imap/fetch-messages-in-category.js index ba3f3e808..745dd5b10 100644 --- a/packages/nylas-sync/imap/fetch-messages-in-category.js +++ b/packages/nylas-sync/imap/fetch-messages-in-category.js @@ -4,7 +4,7 @@ const Imap = require('imap'); const {IMAPConnection, PubsubConnector} = require('nylas-core'); const {Capabilities} = IMAPConnection; -const MessageFlagAttributes = ['id', 'categoryUID', 'unread', 'starred'] +const MessageFlagAttributes = ['id', 'categoryImapUID', 'unread', 'starred'] class FetchMessagesInCategory { constructor(category, options) { @@ -34,7 +34,7 @@ class FetchMessagesInCategory { const {Message} = this._db; return this._db.sequelize.transaction((transaction) => Message.update({ - categoryUID: null, + categoryImapUID: null, categoryId: null, }, { transaction: transaction, @@ -48,7 +48,7 @@ class FetchMessagesInCategory { _updateMessageAttributes(remoteUIDAttributes, localMessageAttributes) { const messageAttributesMap = {}; for (const msg of localMessageAttributes) { - messageAttributesMap[msg.categoryUID] = msg; + messageAttributesMap[msg.categoryImapUID] = msg; } const createdUIDs = []; @@ -90,8 +90,8 @@ class FetchMessagesInCategory { const {Message} = this._db; const removedUIDs = localMessageAttributes - .filter(msg => !remoteUIDAttributes[msg.categoryUID]) - .map(msg => msg.categoryUID) + .filter(msg => !remoteUIDAttributes[msg.categoryImapUID]) + .map(msg => msg.categoryImapUID) console.log(` --- found ${removedUIDs.length} messages no longer in the folder`) @@ -100,13 +100,13 @@ class FetchMessagesInCategory { } return this._db.sequelize.transaction((transaction) => Message.update({ - categoryUID: null, + categoryImapUID: null, categoryId: null, }, { transaction, where: { categoryId: this._category.id, - categoryUID: removedUIDs, + categoryImapUID: removedUIDs, }, }) ); @@ -218,10 +218,10 @@ class FetchMessagesInCategory { unread: !attributes.flags.includes('\\Seen'), starred: attributes.flags.includes('\\Flagged'), date: attributes.date, - categoryUID: attributes.uid, + categoryImapUID: attributes.uid, categoryId: this._category.id, headers: parsedHeaders, - messageId: parsedHeaders['message-id'][0], + headerMessageId: parsedHeaders['message-id'][0], subject: parsedHeaders.subject[0], } diff --git a/packages/nylas-sync/syncback_tasks/move-to-folder.imap.js b/packages/nylas-sync/syncback_tasks/move-to-folder.imap.js index 665306f62..2ad4bd767 100644 --- a/packages/nylas-sync/syncback_tasks/move-to-folder.imap.js +++ b/packages/nylas-sync/syncback_tasks/move-to-folder.imap.js @@ -12,7 +12,7 @@ class MoveToFolderIMAP extends SyncbackTask { const eachMsg = ({message, box}) => { return db.Category.findById(toFolderId).then((category) => { - return box.moveFromBox(message.categoryUID, category.name) + return box.moveFromBox(message.categoryImapUID, category.name) }) }