feat: serve message fetches from the cache

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-10-07 22:20:13 -04:00
parent b1e92e5b07
commit 5e458c5bc8
7 changed files with 261 additions and 4 deletions
+25
View File
@@ -480,6 +480,31 @@ class LiveMailService
}
}
/**
* Fetch the full, decoded content of body sections of one message.
*
* @param string[] $partIds e.g. ['1.2']
* @return array<string, string> content keyed by part id; sections the server did not return are absent
*/
public function messageSections(string $collection, int $uid, string ...$partIds): array
{
if ($partIds === []) {
return [];
}
// BODYSTRUCTURE lets the parser decode each section by its transfer encoding and charset
$options = FetchOptions::of('BODYSTRUCTURE');
foreach ($partIds as $partId) {
$options = $options->withBodySection($partId);
}
foreach ($this->messageFetch($collection, $options, $uid) as $message) {
return array_intersect_key($message->bodySections(), array_flip($partIds));
}
return [];
}
/**
* Stream the raw bytes of a message or a specific MIME part without buffering.
*