Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/IMAP
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-10-15 12:24:38 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-10-30 19:16:24 +0300
commit15867528b25cad3e1262014d0fa4f967a73d64be (patch)
tree6dd7c46876325acf8aad147b9ef791a73376c102 /lib/IMAP
parentfe074001833362fa1eb4d18576131b0678907fb5 (diff)
Store special mailboxes as preference of the account
… instead of using a fragile autodetection every time we need one of those. We will still try to auto-detect the mailboxes but the users will have to option to change the destinations. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/IMAP')
-rw-r--r--lib/IMAP/MailboxSync.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/IMAP/MailboxSync.php b/lib/IMAP/MailboxSync.php
index 15df59453..343abfa56 100644
--- a/lib/IMAP/MailboxSync.php
+++ b/lib/IMAP/MailboxSync.php
@@ -29,7 +29,9 @@ use Horde_Imap_Client;
use Horde_Imap_Client_Data_Namespace;
use Horde_Imap_Client_Exception;
use Horde_Imap_Client_Namespace_List;
+use OCA\Mail\Events\MailboxesSynchronizedEvent;
use OCA\Mail\Exception\ServiceException;
+use OCP\EventDispatcher\IEventDispatcher;
use Psr\Log\LoggerInterface;
use function in_array;
use function json_encode;
@@ -57,16 +59,21 @@ class MailboxSync {
/** @var ITimeFactory */
private $timeFactory;
+ /** @var IEventDispatcher */
+ private $dispatcher;
+
public function __construct(MailboxMapper $mailboxMapper,
FolderMapper $folderMapper,
MailAccountMapper $mailAccountMapper,
IMAPClientFactory $imapClientFactory,
- ITimeFactory $timeFactory) {
+ ITimeFactory $timeFactory,
+ IEventDispatcher $dispatcher) {
$this->mailboxMapper = $mailboxMapper;
$this->folderMapper = $folderMapper;
$this->mailAccountMapper = $mailAccountMapper;
$this->imapClientFactory = $imapClientFactory;
$this->timeFactory = $timeFactory;
+ $this->dispatcher = $dispatcher;
}
/**
@@ -98,7 +105,7 @@ class MailboxSync {
} catch (Horde_Imap_Client_Exception $e) {
throw new ServiceException(
"IMAP error: " . $e->getMessage(),
- (int) $e->getCode(),
+ (int)$e->getCode(),
$e
);
}
@@ -113,6 +120,10 @@ class MailboxSync {
);
$this->persist($account, $folders, $indexedOld);
+
+ $this->dispatcher->dispatchTyped(
+ new MailboxesSynchronizedEvent($account)
+ );
}
private function persist(Account $account, array $folders, array $existing): void {