Mailspring/packages/nylas-sync/syncback_tasks/move-message-to-folder.imap.js

22 lines
660 B
JavaScript
Raw Normal View History

const SyncbackTask = require('./syncback-task')
const TaskHelpers = require('./task-helpers')
class MoveMessageToFolderIMAP extends SyncbackTask {
description() {
return `MoveMessageToFolder`;
}
run(db, imap) {
const messageId = this.syncbackRequestObject().props.messageId
const toFolderId = this.syncbackRequestObject().props.folderId
return TaskHelpers.openMessageBox({messageId, db, imap})
.then(({box, message}) => {
return db.Folder.findById(toFolderId).then((newFolder) => {
return box.moveFromBox(message.folderImapUID, newFolder.name)
})
})
}
}
module.exports = MoveMessageToFolderIMAP