diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php index c9c949081..2a8e8bfef 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php @@ -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() + ); + } } diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Attachment.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Attachment.php index a7bda055e..81cdf87d8 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Attachment.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Attachment.php @@ -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()); } } diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index 02ff6de71..ca69b00e1 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -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;