refactor: split service into ServiceBase and LiveService

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-10-07 21:49:31 -04:00
parent eea9b5630a
commit 4e12d41ee9
18 changed files with 649 additions and 516 deletions
+8 -6
View File
@@ -14,7 +14,7 @@ use KTXM\ProviderImap\Client\Protocol\Command\Argument\FetchOptions;
use KTXM\ProviderImap\Client\Protocol\Parser\FetchMessageParser;
use KTXM\ProviderImap\Providers\CollectionResource;
use KTXM\ProviderImap\Providers\EntityResource;
use KTXM\ProviderImap\Providers\Service;
use KTXM\ProviderImap\Providers\LiveService;
use KTXM\ProviderImap\Service\Cache\HarmonizationService;
use KTXM\ProviderImap\Service\Cache\MessageDeltaService;
use KTXM\ProviderImap\Service\Cache\MessageIngestor;
@@ -40,7 +40,7 @@ final class MessageHarmonizationTest extends TestCase
$this->messages = new FakeMessageStore($dataStore);
$this->files = new FakeMessageFileStore('/nonexistent');
$service = (new Service())->fromStore(['tid' => 'tenant', 'sid' => 'svc']);
$service = (new LiveService())->fromStore(['tid' => 'tenant', 'sid' => 'svc']);
$this->live = new MessageHarmonizationLiveStub($service);
$this->live->uidValidity = 7;
$this->live->uidNext = 100;
@@ -286,14 +286,16 @@ final class MessageHarmonizationLiveStub extends LiveMailService
/** @var string[] */
public array $failing = [];
public function collectionList(?string $location = null, IFilter|null $filter = null, ISort|null $sort = null, string $depth = '*'): Generator
public function collectionList(?string $location = null, ?IFilter $filter = null, ?ISort $sort = null): array
{
$list = [];
foreach ($this->mailboxList as $mailbox) {
yield $mailbox->name() => $mailbox;
$list[$mailbox->name()] = (new CollectionResource('imap', 'svc'))->fromImap($mailbox);
}
return $list;
}
public function collectionFetch(string $identifier): ?Mailbox
public function mailboxFetch(string $identifier): ?Mailbox
{
if (in_array($identifier, $this->failing, true)) {
return null;
@@ -307,7 +309,7 @@ final class MessageHarmonizationLiveStub extends LiveMailService
yield from $this->flags;
}
public function entityFetch(string $collection, ?FetchOptions $options = null, int ...$uids): Generator
public function messageFetch(string $collection, ?FetchOptions $options = null, int ...$uids): Generator
{
$this->fetchBatches[] = $uids;
if (preg_match('/BODY\.PEEK\[TEXT\]<0\.(\d+)>/', (string) $options?->toCommand(), $matches) === 1) {