generated from Nodarx/template
refactor: use custom imap client
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -10,8 +10,7 @@ declare(strict_types=1);
|
||||
namespace KTXM\ProviderImap\Providers;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Gricob\IMAP\Mime\Part\Part;
|
||||
use Gricob\IMAP\Protocol\Response\Line\Data\FetchData;
|
||||
use KTXM\ProviderImap\Client\Message;
|
||||
use KTXF\Mail\Entity\EntityMutableAbstract;
|
||||
|
||||
/**
|
||||
@@ -27,25 +26,19 @@ class EntityResource extends EntityMutableAbstract {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert gricob FetchData to mail entity object
|
||||
*
|
||||
* @param FetchData $fetchData result from IMAP FETCH command
|
||||
* @param string $mailbox IMAP mailbox name (used as collection)
|
||||
* Convert IMAP data to a mail entity object.
|
||||
*/
|
||||
public function fromImap(FetchData $fetchData, string $mailbox): static {
|
||||
|
||||
// Collection = the IMAP mailbox name
|
||||
public function fromImap(Message $message, string $mailbox): static
|
||||
{
|
||||
$this->data['collection'] = $mailbox;
|
||||
|
||||
// Identifier = UID (preferred) or sequence number as fallback
|
||||
$this->data['identifier'] = $fetchData->uid ?? $fetchData->id;
|
||||
$this->data['identifier'] = $message->uid() ?: $message->sequence();
|
||||
|
||||
// Created = INTERNALDATE (server arrival time)
|
||||
if ($fetchData->internalDate !== null) {
|
||||
$this->data['created'] = $fetchData->internalDate->format(DateTimeInterface::ATOM);
|
||||
if ($message->internalDate() !== null) {
|
||||
$this->data['created'] = $message->internalDate();
|
||||
}
|
||||
|
||||
$this->getProperties()->fromImap($fetchData);
|
||||
$this->getProperties()->fromImap($message);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user