mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 03:59:21 +03:00
Improve MailSo\Imap\BodyStructure
This commit is contained in:
parent
3d63eeb79e
commit
87df281434
3 changed files with 24 additions and 20 deletions
|
|
@ -17,7 +17,7 @@ use MailSo\Mime\ParameterCollection;
|
|||
* @category MailSo
|
||||
* @package Imap
|
||||
*/
|
||||
class BodyStructure
|
||||
class BodyStructure implements \JsonSerializable
|
||||
{
|
||||
private string $sContentType;
|
||||
|
||||
|
|
@ -43,6 +43,9 @@ class BodyStructure
|
|||
|
||||
private string $sPartID;
|
||||
|
||||
/**
|
||||
* \MailSo\Imap\BodyStructure[]
|
||||
*/
|
||||
private array $aSubParts;
|
||||
|
||||
public function MailEncodingName() : string
|
||||
|
|
@ -561,4 +564,19 @@ class BodyStructure
|
|||
|
||||
return $aDict;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return array(
|
||||
'MimeIndex' => $this->PartID(),
|
||||
'MimeType' => $this->ContentType(),
|
||||
'MimeTypeParams' => $this->ContentTypeParameters(),
|
||||
'FileName' => \MailSo\Base\Utils::SecureFileName($this->FileName(true)),
|
||||
'EstimatedSize' => $this->EstimatedSize(),
|
||||
'Cid' => $this->ContentID(),
|
||||
'ContentLocation' => $this->ContentLocation(),
|
||||
'IsInline' => $this->IsInline()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,11 +51,6 @@ class Attachment implements \JsonSerializable
|
|||
return $this->iUid;
|
||||
}
|
||||
|
||||
public function FileName(bool $bCalculateOnEmpty = false) : string
|
||||
{
|
||||
return $this->oBodyStructure ? $this->oBodyStructure->FileName($bCalculateOnEmpty) : '';
|
||||
}
|
||||
|
||||
public function __call(string $name, array $arguments) //: mixed
|
||||
{
|
||||
return $this->oBodyStructure->{$name}(...$arguments);
|
||||
|
|
@ -64,18 +59,10 @@ class Attachment implements \JsonSerializable
|
|||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return array(
|
||||
return \array_merge([
|
||||
'@Object' => 'Object/Attachment',
|
||||
'Folder' => $this->sFolder,
|
||||
'Uid' => $this->iUid,
|
||||
'MimeIndex' => $this->oBodyStructure->PartID(),
|
||||
'MimeType' => $this->oBodyStructure->ContentType(),
|
||||
'MimeTypeParams' => $this->oBodyStructure->ContentTypeParameters(),
|
||||
'FileName' => \MailSo\Base\Utils::SecureFileName($this->FileName(true)),
|
||||
'EstimatedSize' => $this->oBodyStructure->EstimatedSize(),
|
||||
'Cid' => $this->oBodyStructure->ContentID(),
|
||||
'ContentLocation' => $this->oBodyStructure->ContentLocation(),
|
||||
'IsInline' => $this->oBodyStructure->IsInline()
|
||||
);
|
||||
'Uid' => $this->iUid
|
||||
], $this->oBodyStructure->jsonSerialize());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,15 +133,14 @@ class MailClient
|
|||
$this->getEnvelopeOrHeadersRequestString()
|
||||
);
|
||||
|
||||
$iBodyTextLimit = $this->oImapClient->Settings->body_text_limit;
|
||||
|
||||
$aFetchResponse = $this->oImapClient->Fetch(array(FetchType::BODYSTRUCTURE), $iIndex, $bIndexIsUid);
|
||||
if (\count($aFetchResponse) && isset($aFetchResponse[0])) {
|
||||
$oBodyStructure = $aFetchResponse[0]->GetFetchBodyStructure();
|
||||
if ($oBodyStructure) {
|
||||
$iBodyTextLimit = $this->oImapClient->Settings->body_text_limit;
|
||||
foreach ($oBodyStructure->GetHtmlAndPlainParts() as $oPart) {
|
||||
$sLine = FetchType::BODY_PEEK.'['.$oPart->PartID().']';
|
||||
if (0 < $iBodyTextLimit && $iBodyTextLimit < $oPart->Size()) {
|
||||
if (0 < $iBodyTextLimit && $iBodyTextLimit < $oPart->EstimatedSize()) {
|
||||
$sLine .= "<0.{$iBodyTextLimit}>";
|
||||
}
|
||||
$aFetchItems[] = $sLine;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue