generated from Nodarx/template
feat: implement content cache
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -105,6 +105,7 @@ class EntityResource extends EntityMutableAbstract {
|
||||
return [
|
||||
'schemaVersion' => self::CACHE_SCHEMA_VERSION,
|
||||
'created' => $this->data['created'] ?? null,
|
||||
'incomplete' => $this->getProperties()->getIncompleteSections(),
|
||||
'properties' => $this->getProperties()->toCacheContent(),
|
||||
];
|
||||
}
|
||||
@@ -124,7 +125,9 @@ class EntityResource extends EntityMutableAbstract {
|
||||
$this->data['created'] = $content['created'];
|
||||
}
|
||||
|
||||
$this->getProperties()->fromCacheContent($content['properties'] ?? []);
|
||||
$this->getProperties()
|
||||
->fromCacheContent($content['properties'] ?? [])
|
||||
->setIncompleteSections(...array_map('strval', $content['incomplete'] ?? []));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,20 @@ use KTXF\Mail\Object\MessagePropertiesMutableAbstract;
|
||||
*/
|
||||
class MessageProperties extends MessagePropertiesMutableAbstract {
|
||||
|
||||
/**
|
||||
* Part ids of text sections that were cut off when fetched (cache only, not part of the API shape)
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
private array $incompleteSections = [];
|
||||
|
||||
/**
|
||||
* Convert IMAP data to mail message properties object.
|
||||
*/
|
||||
public function fromImap(Message $message): static
|
||||
{
|
||||
$this->data[static::PROPERTY_SIZE] = $message->size();
|
||||
$this->incompleteSections = $message->truncatedSections();
|
||||
|
||||
if ($message->messageId() !== null) {
|
||||
$this->data[static::PROPERTY_URID] = $message->messageId();
|
||||
@@ -111,6 +119,22 @@ class MessageProperties extends MessagePropertiesMutableAbstract {
|
||||
|
||||
// ── Cache (meta store / content store) ───────────────────────────────────
|
||||
|
||||
/**
|
||||
* Part ids of text sections that were cut off when fetched and must be completed on open.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getIncompleteSections(): array
|
||||
{
|
||||
return $this->incompleteSections;
|
||||
}
|
||||
|
||||
public function setIncompleteSections(string ...$partIds): static
|
||||
{
|
||||
$this->incompleteSections = array_values(array_unique($partIds));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialise the fields the meta store needs for list, filter and sort.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user