mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 12:40:08 +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.Category.findById(toFolderId).then((category) => {
|
|
return box.moveFromBox(message.categoryUID, category.name)
|
|
})
|
|
}
|
|
|
|
return TaskHelpers.forEachMessageInThread({threadId, db, imap, callback: eachMsg})
|
|
}
|
|
}
|
|
module.exports = MoveToFolderIMAP
|