1010
1111use Horde_Imap_Client_Exception ;
1212use OCA \Mail \AppInfo \Application ;
13+ use OCA \Mail \Db \MailAccount ;
1314use OCA \Mail \Exception \IncompleteSyncException ;
1415use OCA \Mail \Exception \ServiceException ;
15- use OCA \Mail \IMAP \ MailboxSync ;
16+ use OCA \Mail \Protocol \ ProtocolFactory ;
1617use OCA \Mail \Service \AccountService ;
17- use OCA \Mail \Service \Sync \ImapToDbSynchronizer ;
1818use OCP \AppFramework \Db \DoesNotExistException ;
1919use OCP \AppFramework \Utility \ITimeFactory ;
2020use OCP \BackgroundJob \IJobList ;
@@ -31,8 +31,6 @@ class SyncJob extends TimedJob {
3131
3232 private IUserManager $ userManager ;
3333 private AccountService $ accountService ;
34- private ImapToDbSynchronizer $ syncService ;
35- private MailboxSync $ mailboxSync ;
3634 private LoggerInterface $ logger ;
3735 private IJobList $ jobList ;
3836 private readonly bool $ forcedSyncInterval ;
@@ -41,8 +39,7 @@ public function __construct(
4139 ITimeFactory $ time ,
4240 IUserManager $ userManager ,
4341 AccountService $ accountService ,
44- MailboxSync $ mailboxSync ,
45- ImapToDbSynchronizer $ syncService ,
42+ private ProtocolFactory $ protocolFactory ,
4643 LoggerInterface $ logger ,
4744 IJobList $ jobList ,
4845 private readonly IConfig $ config ,
@@ -51,8 +48,6 @@ public function __construct(
5148
5249 $ this ->userManager = $ userManager ;
5350 $ this ->accountService = $ accountService ;
54- $ this ->syncService = $ syncService ;
55- $ this ->mailboxSync = $ mailboxSync ;
5651 $ this ->logger = $ logger ;
5752 $ this ->jobList = $ jobList ;
5853
@@ -83,7 +78,8 @@ protected function run($argument) {
8378 return ;
8479 }
8580
86- if (!$ account ->getMailAccount ()->canAuthenticateImap ()) {
81+ if ($ account ->getMailAccount ()->getProtocol () === MailAccount::PROTOCOL_IMAP
82+ && !$ account ->getMailAccount ()->canAuthenticateImap ()) {
8783 $ this ->logger ->debug ('No authentication on IMAP possible, skipping background sync job ' );
8884 return ;
8985 }
@@ -124,8 +120,12 @@ protected function run($argument) {
124120 }
125121
126122 try {
127- $ this ->mailboxSync ->sync ($ account , $ this ->logger , true );
128- $ this ->syncService ->syncAccount ($ account , $ this ->logger );
123+ $ this ->protocolFactory
124+ ->mailboxConnector ($ account )
125+ ->syncMailboxList ($ account , $ this ->logger , true );
126+ $ this ->protocolFactory
127+ ->messageConnector ($ account )
128+ ->syncAccount ($ account , $ this ->logger , true );
129129 } catch (IncompleteSyncException $ e ) {
130130 $ this ->logger ->warning ($ e ->getMessage (), [
131131 'exception ' => $ e ,
0 commit comments