Mailspring/packages/local-sync/src/local-sync-worker/syncback_tasks/delete-message.imap.js
Juan Tejada fda7fe18cc [local-sync] Ensure order correct order when running syncback requests
When running syncback requests, if a task is meant to change the UID of
a message (e.g. move it to a new folder), that task should be run after
other tasks that don't affect the UID. Otherwise, when trying to run the
other tasks, they would reference a UID that is no longer valid.

This commit will make sure that we run any tasks that will change message uids last,
/and/ make sure that we don't run more than 1 task that will affect the uids of
the same messages in a row (i.e. without running a sync loop in between)
2016-12-06 15:45:34 -08:00

19 lines
520 B
JavaScript

const SyncbackTask = require('./syncback-task')
const TaskHelpers = require('./task-helpers')
class DeleteMessageIMAP extends SyncbackTask {
description() {
return `DeleteMessage`;
}
affectsImapMessageUIDs() {
return false
}
async run(db, imap) {
const messageId = this.syncbackRequestObject().props.messageId
const {box, message} = await TaskHelpers.openMessageBox({messageId, db, imap})
return box.addFlags(message.folderImapUID, ['DELETED'])
}
}
module.exports = DeleteMessageIMAP;