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

23 lines
661 B
JavaScript
Raw Normal View History

2016-06-30 01:13:48 +08:00
const SyncbackTask = require('./syncback-task')
2016-06-30 02:44:30 +08:00
const TaskHelpers = require('./task-helpers')
2016-06-30 01:11:53 +08:00
2016-06-30 01:13:48 +08:00
class MoveToFolderIMAP extends SyncbackTask {
2016-06-29 05:07:54 +08:00
description() {
return `MoveToFolder`;
}
run(db, imap) {
2016-06-30 02:44:30 +08:00
const threadId = this.syncbackRequestObject().props.threadId
const toFolderId = this.syncbackRequestObject().props.folderId
const eachMsg = ({message, box}) => {
return db.Folder.findById(toFolderId).then((category) => {
return box.moveFromBox(message.folderImapUID, category.name)
2016-06-30 05:00:47 +08:00
})
2016-06-30 02:44:30 +08:00
}
return TaskHelpers.forEachMessageInThread({threadId, db, imap, callback: eachMsg})
2016-06-29 05:07:54 +08:00
}
}
module.exports = MoveToFolderIMAP