mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-13 13:19:34 +08:00
42 lines
1.7 KiB
JavaScript
42 lines
1.7 KiB
JavaScript
/**
|
|
* Given a `SyncbackRequestObject` it creates the appropriate syncback task.
|
|
*
|
|
*/
|
|
class SyncbackTaskFactory {
|
|
static create(account, syncbackRequest) {
|
|
let Task = null;
|
|
switch (syncbackRequest.type) {
|
|
case "MoveToFolder":
|
|
Task = require('./syncback_tasks/move-to-folder.imap'); break;
|
|
case "MarkThreadAsRead":
|
|
Task = require('./syncback_tasks/mark-thread-as-read.imap'); break;
|
|
case "MarkThreadAsUnread":
|
|
Task = require('./syncback_tasks/mark-thread-as-unread.imap'); break;
|
|
case "StarThread":
|
|
Task = require('./syncback_tasks/star-thread.imap'); break;
|
|
case "UnstarThread":
|
|
Task = require('./syncback_tasks/unstar-thread.imap'); break;
|
|
case "MoveMessageToFolder":
|
|
Task = require('./syncback_tasks/move-message-to-folder.imap'); break;
|
|
case "MarkMessageAsRead":
|
|
Task = require('./syncback_tasks/mark-message-as-read.imap'); break;
|
|
case "MarkMessageAsUnread":
|
|
Task = require('./syncback_tasks/mark-message-as-unread.imap'); break;
|
|
case "StarMessage":
|
|
Task = require('./syncback_tasks/star-message.imap'); break;
|
|
case "UnstarMessage":
|
|
Task = require('./syncback_tasks/unstar-message.imap'); break;
|
|
case "CreateFolder":
|
|
Task = require('./syncback_tasks/create-folder.imap'); break;
|
|
case "RenameFolder":
|
|
Task = require('./syncback_tasks/rename-folder.imap'); break;
|
|
case "DeleteFolder":
|
|
Task = require('./syncback_tasks/delete-folder.imap'); break;
|
|
default:
|
|
throw new Error(`Invalid Task Type: ${syncbackRequest.type}`)
|
|
}
|
|
return new Task(account, syncbackRequest)
|
|
}
|
|
}
|
|
|
|
module.exports = SyncbackTaskFactory
|