2016-06-30 09:52:58 +08:00
|
|
|
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}) => {
|
2016-07-01 00:29:21 +08:00
|
|
|
return db.Folder.findById(toFolderId).then((newFolder) => {
|
|
|
|
return box.moveFromBox(message.folderImapUID, newFolder.name)
|
2016-06-30 09:52:58 +08:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = MoveMessageToFolderIMAP
|