refactor: use custom imap client

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-08 00:16:43 -04:00
parent a728aeb11c
commit a8764747fd
179 changed files with 6782 additions and 5907 deletions

View File

@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace KTXM\ProviderImap\Providers;
use Gricob\IMAP\Mailbox;
use KTXM\ProviderImap\Client\Mailbox;
use KTXF\Mail\Collection\CollectionMutableAbstract;
/**
@@ -29,26 +29,27 @@ class CollectionResource extends CollectionMutableAbstract
// ── IMAP hydration ───────────────────────────────────────────────────────
/**
* Populate from a gricob Mailbox object.
* Populate from a standalone IMAP Mailbox value object.
*
* @param Mailbox $mailbox gricob Mailbox value object from LIST response
* @param Mailbox $mailbox mailbox value object from LIST response
* @param array $options additional options, e.g., ['delimiter' => '/']
*/
public function fromImap(Mailbox $mailbox): static
public function fromImap(Mailbox $mailbox, array $options = []): static
{
// The mailbox name is its unique identifier within the account
$this->data['identifier'] = $mailbox->name;
$this->data['identifier'] = $mailbox->name();
// Derive parent collection from path + delimiter
$delimiter = $mailbox->hierarchyDelimiter;
if ($delimiter && str_contains($mailbox->name, $delimiter)) {
$parts = explode($delimiter, $mailbox->name);
$delimiter = $mailbox->delimiter() ?? $options['delimiter'] ?? '/';
if ($delimiter && str_contains($mailbox->name(), $delimiter)) {
$parts = explode($delimiter, $mailbox->name());
array_pop($parts);
$this->data['collection'] = implode($delimiter, $parts);
} else {
$this->data['collection'] = null;
$this->data['collection'] = null; // top-level mailbox
}
$this->getProperties()->fromImap($mailbox);
$this->getProperties()->fromImap($mailbox, $options);
return $this;
}