-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! fix(imap): persist vanished messages immediately on EXAMINE co…
…mmands
- Loading branch information
Showing
2 changed files
with
8 additions
and
89 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,23 +11,15 @@ | |
|
||
use Horde_Imap_Client; | ||
use Horde_Imap_Client_Socket; | ||
use OC\Memcache\Redis; | ||
use OCA\Mail\Account; | ||
use OCA\Mail\Contracts\IMailManager; | ||
use OCA\Mail\Controller\MailboxesController; | ||
use OCA\Mail\Db\MailboxMapper; | ||
use OCA\Mail\Db\MessageMapper as DbMessageMapper; | ||
use OCA\Mail\IMAP\MessageMapper as ImapMessageMapper; | ||
use OCA\Mail\IMAP\Sync\Synchronizer; | ||
use OCA\Mail\Service\AccountService; | ||
use OCA\Mail\Service\Sync\ImapToDbSynchronizer; | ||
use OCA\Mail\Service\Sync\SyncService; | ||
use OCA\Mail\Support\PerformanceLogger; | ||
use OCA\Mail\Tests\Integration\Framework\Caching; | ||
use OCA\Mail\Tests\Integration\Framework\ImapTest; | ||
use OCA\Mail\Tests\Integration\Framework\ImapTestAccount; | ||
use OCP\EventDispatcher\IEventDispatcher; | ||
use OCP\IConfig; | ||
use OCP\IRequest; | ||
use OCP\Server; | ||
use Psr\Log\LoggerInterface; | ||
|
@@ -233,20 +225,6 @@ public function testSyncVanishedMessage() { | |
} | ||
|
||
public function testUnsolicitedVanishedMessage() { | ||
$config = Server::get(IConfig::class); | ||
$cacheClass = $config->getSystemValueString('memcache.distributed'); | ||
if (ltrim($cacheClass, '\\') !== Redis::class) { | ||
$this->markTestSkipped('Redis not available. Found ' . $cacheClass); | ||
} | ||
|
||
[$imapClientFactory, $cacheFactory] = Caching::getImapClientFactoryAndConfiguredCacheFactory(); | ||
|
||
// Just to be sure ... | ||
$cache = $cacheFactory->createDistributed(); | ||
$this->assertInstanceOf(Redis::class, $cache); | ||
|
||
$cache->clear(); | ||
|
||
$mailbox = 'INBOX'; | ||
$message = $this->getMessageBuilder() | ||
->from('ralph@[email protected]') | ||
|
@@ -282,36 +260,27 @@ public function testUnsolicitedVanishedMessage() { | |
); | ||
|
||
// Trigger partial sync to warm the cache. | ||
// Construct a new ImapToDbSynchronizer from scratch to prevent getting a cached instance | ||
// without the proper ICacheFactory that still builds instances of ArrayCache despite Redis | ||
// being configured. | ||
$dbMessageMapper = Server::get(DbMessageMapper::class); | ||
$logger = Server::get(LoggerInterface::class); | ||
$synchronizer = new ImapToDbSynchronizer( | ||
$dbMessageMapper, | ||
$imapClientFactory, | ||
Server::get(ImapMessageMapper::class), | ||
Server::get(MailboxMapper::class), | ||
Server::get(Synchronizer::class), | ||
Server::get(IEventDispatcher::class), | ||
Server::get(PerformanceLogger::class), | ||
$logger, | ||
Server::get(IMailManager::class), | ||
$synchronizer = Server::get(ImapToDbSynchronizer::class); | ||
$synchronizer->syncAccount( | ||
new Account($this->account), | ||
Server::get(LoggerInterface::class), | ||
); | ||
$synchronizer->syncAccount(new Account($this->account), $logger); | ||
|
||
// Assert that there are 2 messages and nothing changes when deleting a message externally | ||
$dbMessageMapper = Server::get(DbMessageMapper::class); | ||
self::assertCount(2, $dbMessageMapper->findAllUids($inbox)); | ||
$this->deleteMessagesExternally($mailbox, [$uid1]); | ||
self::assertCount(2, $dbMessageMapper->findAllUids($inbox)); | ||
|
||
// Receive unsolicited vanished uid | ||
$client = $this->getClient($this->account); | ||
$mailManager->getSource( | ||
$imapClientFactory->getClient(new Account($this->account)), | ||
$client, | ||
new Account($this->account), | ||
$mailbox, | ||
$uid2, | ||
); | ||
$client->logout(); | ||
|
||
// Assert that the unsolicited change was synced to the db | ||
self::assertCount(1, $dbMessageMapper->findAllUids($inbox)); | ||
|