diff options
author | Anna Larch <anna@nextcloud.com> | 2021-03-27 03:36:53 +0300 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2021-03-31 19:32:24 +0300 |
commit | 49138926a8d87e3228edee376e0d919d81f407ac (patch) | |
tree | f477c359cb66bcc9a2d5d0e53ea4b9d877021b92 /lib/Service | |
parent | 1910e08c86ab34b038a3ce13063a1ed8b36f118a (diff) |
Rework duplicate entry handling for tags
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'lib/Service')
-rw-r--r-- | lib/Service/Classification/ImportanceClassifier.php | 2 | ||||
-rw-r--r-- | lib/Service/CleanupService.php | 10 | ||||
-rw-r--r-- | lib/Service/Search/MailSearch.php | 4 | ||||
-rw-r--r-- | lib/Service/Sync/SyncService.php | 6 |
4 files changed, 15 insertions, 7 deletions
diff --git a/lib/Service/Classification/ImportanceClassifier.php b/lib/Service/Classification/ImportanceClassifier.php index f20727b1d..fd0a50321 100644 --- a/lib/Service/Classification/ImportanceClassifier.php +++ b/lib/Service/Classification/ImportanceClassifier.php @@ -164,7 +164,7 @@ class ImportanceClassifier { return $mailbox->getId(); }, $incomingMailboxes); $messages = array_filter( - $this->messageMapper->findLatestMessages($mailboxIds, self::MAX_TRAINING_SET_SIZE), + $this->messageMapper->findLatestMessages($account->getUserId(), $mailboxIds, self::MAX_TRAINING_SET_SIZE), [$this, 'filterMessageHasSenderEmail'] ); $importantMessages = array_filter($messages, function (Message $message) { diff --git a/lib/Service/CleanupService.php b/lib/Service/CleanupService.php index 97a6c2f35..ff41feb32 100644 --- a/lib/Service/CleanupService.php +++ b/lib/Service/CleanupService.php @@ -29,6 +29,7 @@ use OCA\Mail\Db\AliasMapper; use OCA\Mail\Db\CollectedAddressMapper; use OCA\Mail\Db\MailboxMapper; use OCA\Mail\Db\MessageMapper; +use OCA\Mail\Db\TagMapper; class CleanupService { @@ -44,14 +45,19 @@ class CleanupService { /** @var CollectedAddressMapper */ private $collectedAddressMapper; + /** @var TagMapper */ + private $tagMapper; + public function __construct(AliasMapper $aliasMapper, MailboxMapper $mailboxMapper, MessageMapper $messageMapper, - CollectedAddressMapper $collectedAddressMapper) { + CollectedAddressMapper $collectedAddressMapper, + TagMapper $tagMapper) { $this->aliasMapper = $aliasMapper; $this->mailboxMapper = $mailboxMapper; $this->messageMapper = $messageMapper; $this->collectedAddressMapper = $collectedAddressMapper; + $this->tagMapper = $tagMapper; } public function cleanUp(): void { @@ -59,5 +65,7 @@ class CleanupService { $this->mailboxMapper->deleteOrphans(); $this->messageMapper->deleteOrphans(); $this->collectedAddressMapper->deleteOrphans(); + $this->tagMapper->deleteOrphans(); + $this->tagMapper->deleteDuplicates(); } } diff --git a/lib/Service/Search/MailSearch.php b/lib/Service/Search/MailSearch.php index fc233689b..9f50e26ca 100644 --- a/lib/Service/Search/MailSearch.php +++ b/lib/Service/Search/MailSearch.php @@ -130,7 +130,7 @@ class MailSearch implements IMailSearch { return $this->previewEnhancer->process( $account, $mailbox, - $this->messageMapper->findByIds( + $this->messageMapper->findByIds($account->getUserId(), $this->getIdsLocally($account, $mailbox, $query, $limit) ) ); @@ -155,7 +155,7 @@ class MailSearch implements IMailSearch { $query->setCursor($cursor); } - return $this->messageMapper->findByIds( + return $this->messageMapper->findByIds($user->getUID(), $this->getIdsGlobally($user, $query, $limit) ); } diff --git a/lib/Service/Sync/SyncService.php b/lib/Service/Sync/SyncService.php index 3919508ff..c3a41c1f0 100644 --- a/lib/Service/Sync/SyncService.php +++ b/lib/Service/Sync/SyncService.php @@ -155,16 +155,16 @@ class SyncService { $newUids = $this->messageMapper->findUidsForIds($mailbox, $newIds); $newIds = $this->messageMapper->findIdsByQuery($mailbox, $query, null, $newUids); } - $new = $this->messageMapper->findByIds($newIds); + $new = $this->messageMapper->findByIds($account->getUserId(), $newIds); - // TODO: $changed = $this->messageMapper->findChanged($mailbox, $uids); + // TODO: $changed = $this->messageMapper->findChanged($account, $mailbox, $uids); if ($query !== null) { $changedUids = $this->messageMapper->findUidsForIds($mailbox, $knownIds); $changedIds = $this->messageMapper->findIdsByQuery($mailbox, $query, null, $changedUids); } else { $changedIds = $knownIds; } - $changed = $this->messageMapper->findByIds($changedIds); + $changed = $this->messageMapper->findByIds($account->getUserId(), $changedIds); $stillKnownIds = array_map(static function (Message $msg) { return $msg->getId(); |