generated from Nodarx/template
refactor: use custom imap client
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -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\CollectionPropertiesMutableAbstract;
|
||||
use KTXF\Mail\Collection\CollectionRoles;
|
||||
|
||||
@@ -24,26 +24,28 @@ class CollectionProperties extends CollectionPropertiesMutableAbstract
|
||||
// ── IMAP hydration ───────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Populate from a gricob Mailbox object.
|
||||
* Populate from a standalone IMAP Mailbox value object.
|
||||
*
|
||||
* Total / unread counts are NOT available from a LIST response alone.
|
||||
* They must be set separately (after SELECT + SEARCH UNSEEN).
|
||||
* Total / unread counts are available when the caller uses LIST-STATUS.
|
||||
*/
|
||||
public function fromImap(Mailbox $mailbox): static
|
||||
public function fromImap(Mailbox $mailbox, array $options = []): static
|
||||
{
|
||||
$delimiter = $mailbox->hierarchyDelimiter;
|
||||
$this->data['label'] = ($delimiter !== '' && str_contains($mailbox->name, $delimiter))
|
||||
? substr($mailbox->name, strrpos($mailbox->name, $delimiter) + strlen($delimiter))
|
||||
: $mailbox->name;
|
||||
$delimiter = $mailbox->delimiter() ?? '';
|
||||
$name = $mailbox->name();
|
||||
$attributes = $mailbox->attributes();
|
||||
|
||||
$this->data['label'] = ($delimiter !== '' && str_contains($name, $delimiter))
|
||||
? substr($name, strrpos($name, $delimiter) + strlen($delimiter))
|
||||
: $name;
|
||||
$this->data['delimiter'] = $delimiter;
|
||||
$this->data['attributes'] = $mailbox->nameAttributes;
|
||||
$this->data['subscribed'] = in_array('\Subscribed', $mailbox->nameAttributes, true);
|
||||
$this->data['total'] = 0;
|
||||
$this->data['unread'] = 0;
|
||||
$this->data['attributes'] = $attributes;
|
||||
$this->data['subscribed'] = in_array('\\SUBSCRIBED', $attributes, true) || in_array('\\Subscribed', $attributes, true);
|
||||
$this->data['total'] = $mailbox->messages();
|
||||
$this->data['unread'] = $mailbox->unread();
|
||||
$this->data['rank'] = 0;
|
||||
|
||||
// Map standard IMAP role attributes
|
||||
$this->data['role'] = $this->roleFromAttributes($mailbox->nameAttributes)->value;
|
||||
$this->data['role'] = $this->roleFromAttributes($attributes)->value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -91,6 +93,6 @@ class CollectionProperties extends CollectionPropertiesMutableAbstract
|
||||
return $role;
|
||||
}
|
||||
}
|
||||
return CollectionRoles::Custom;
|
||||
return CollectionRoles::None;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user