Skip to content

Commit

Permalink
Add check for timestamp to hasLocks
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Larch <[email protected]>
  • Loading branch information
miaulalala committed Mar 24, 2021
1 parent f88247e commit df4992d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/Db/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ public function isCached(): bool {
&& $this->getSyncVanishedToken() !== null;
}

public function hasLocks( int $now ): bool {
if( $this->getSyncNewLock() !== null || $this->getSyncNewLock() > ( $now - MailboxMapper::LOCK) ) {
public function hasLocks(int $now): bool {
if ($this->getSyncNewLock() !== null || $this->getSyncNewLock() > ($now - MailboxMapper::LOCK)) {
return true;
}
if( $this->getSyncChangedLock() !== null || $this->getSyncChangedLock() > ( $now - MailboxMapper::LOCK) ) {
if ($this->getSyncChangedLock() !== null || $this->getSyncChangedLock() > ($now - MailboxMapper::LOCK)) {
return true;
}
if( $this->getSyncVanishedLock() !== null || $this->getSyncVanishedLock() > ( $now - MailboxMapper::LOCK) ) {
if ($this->getSyncVanishedLock() !== null || $this->getSyncVanishedLock() > ($now - MailboxMapper::LOCK)) {
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/TagMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function getAllTagsForMessages(array $messages): array {
foreach ($queryResult as $qr) {
$result[] = $qr['imap_message_id'];
$result[$qr['imap_message_id']][] = $this->getTag((int)$qr['tag_id']);
};
}
return $result;
}

Expand Down
8 changes: 7 additions & 1 deletion tests/Unit/Service/Search/MailSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use OCA\Mail\Service\Search\Flag;
use OCA\Mail\Service\Search\MailSearch;
use OCA\Mail\Service\Search\SearchQuery;
use OCP\AppFramework\Utility\ITimeFactory;
use PHPUnit\Framework\MockObject\MockObject;

class MailSearchTest extends TestCase {
Expand All @@ -61,6 +62,9 @@ class MailSearchTest extends TestCase {
/** @var MessageMapper|MockObject */
private $messageMapper;

/** @var ITimeFactory|MockObject */
private $timeFactory;

protected function setUp(): void {
parent::setUp();

Expand All @@ -69,13 +73,15 @@ protected function setUp(): void {
$this->imapSearchProvider = $this->createMock(Provider::class);
$this->messageMapper = $this->createMock(MessageMapper::class);
$this->previewEnhancer = $this->createMock(PreviewEnhancer::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);

$this->search = new MailSearch(
$this->filterStringParser,
$this->mailboxMapper,
$this->imapSearchProvider,
$this->messageMapper,
$this->previewEnhancer
$this->previewEnhancer,
$this->timeFactory
);
}

Expand Down

0 comments on commit df4992d

Please sign in to comment.