mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 13:44:41 +08:00
22 lines
661 B
JavaScript
22 lines
661 B
JavaScript
const SyncbackTask = require('./syncback-task')
|
|
const TaskHelpers = require('./task-helpers')
|
|
|
|
class MoveToFolderIMAP extends SyncbackTask {
|
|
description() {
|
|
return `MoveToFolder`;
|
|
}
|
|
|
|
run(db, imap) {
|
|
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)
|
|
})
|
|
}
|
|
|
|
return TaskHelpers.forEachMessageInThread({threadId, db, imap, callback: eachMsg})
|
|
}
|
|
}
|
|
module.exports = MoveToFolderIMAP
|