mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-01 02:25:45 +08:00
categoryUID -> categoryImapUID and messageId -> messageHeaderId
This commit is contained in:
parent
d3fd671ff6
commit
4d7f728a75
5 changed files with 16 additions and 16 deletions
|
@ -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}`)
|
||||
|
|
|
@ -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: "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
headerMessageId: "<cq08iqwatp00kai4qnff7zbaj-2147483647@mailer.nylas.com>",
|
||||
snippet: "Sagar, Aw, glad to hear it! Thanks for getting in touch! Jackie Luo Software Engineer, Nylas",
|
||||
setThread: (thread) => {
|
||||
reply.thread = thread.id
|
||||
|
|
|
@ -15,7 +15,7 @@ it('parses the message correctly', (done) => {
|
|||
|
||||
processMessage({message}).then((processed) => {
|
||||
expect(processed.headers['in-reply-to']).toEqual('<electron/electron.atom.io/pull/352@github.com>')
|
||||
expect(processed.messageId).toEqual('<electron/electron.atom.io/pull/352/r67715160@github.com>')
|
||||
expect(processed.headerMessageId).toEqual('<electron/electron.atom.io/pull/352/r67715160@github.com>')
|
||||
expect(processed.subject).toEqual('Re: [electron/electron.atom.io] Add Jasper app (#352)')
|
||||
expect(processed.body.includes(bodyPart)).toBe(true)
|
||||
done()
|
||||
|
|
|
@ -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],
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue