mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +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
|
* @category MailSo
|
||||||
* @package Imap
|
* @package Imap
|
||||||
*/
|
*/
|
||||||
class BodyStructure
|
class BodyStructure implements \JsonSerializable
|
||||||
{
|
{
|
||||||
private string $sContentType;
|
private string $sContentType;
|
||||||
|
|
||||||
|
|
@ -43,6 +43,9 @@ class BodyStructure
|
||||||
|
|
||||||
private string $sPartID;
|
private string $sPartID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \MailSo\Imap\BodyStructure[]
|
||||||
|
*/
|
||||||
private array $aSubParts;
|
private array $aSubParts;
|
||||||
|
|
||||||
public function MailEncodingName() : string
|
public function MailEncodingName() : string
|
||||||
|
|
@ -561,4 +564,19 @@ class BodyStructure
|
||||||
|
|
||||||
return $aDict;
|
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;
|
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
|
public function __call(string $name, array $arguments) //: mixed
|
||||||
{
|
{
|
||||||
return $this->oBodyStructure->{$name}(...$arguments);
|
return $this->oBodyStructure->{$name}(...$arguments);
|
||||||
|
|
@ -64,18 +59,10 @@ class Attachment implements \JsonSerializable
|
||||||
#[\ReturnTypeWillChange]
|
#[\ReturnTypeWillChange]
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
return array(
|
return \array_merge([
|
||||||
'@Object' => 'Object/Attachment',
|
'@Object' => 'Object/Attachment',
|
||||||
'Folder' => $this->sFolder,
|
'Folder' => $this->sFolder,
|
||||||
'Uid' => $this->iUid,
|
'Uid' => $this->iUid
|
||||||
'MimeIndex' => $this->oBodyStructure->PartID(),
|
], $this->oBodyStructure->jsonSerialize());
|
||||||
'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()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,15 +133,14 @@ class MailClient
|
||||||
$this->getEnvelopeOrHeadersRequestString()
|
$this->getEnvelopeOrHeadersRequestString()
|
||||||
);
|
);
|
||||||
|
|
||||||
$iBodyTextLimit = $this->oImapClient->Settings->body_text_limit;
|
|
||||||
|
|
||||||
$aFetchResponse = $this->oImapClient->Fetch(array(FetchType::BODYSTRUCTURE), $iIndex, $bIndexIsUid);
|
$aFetchResponse = $this->oImapClient->Fetch(array(FetchType::BODYSTRUCTURE), $iIndex, $bIndexIsUid);
|
||||||
if (\count($aFetchResponse) && isset($aFetchResponse[0])) {
|
if (\count($aFetchResponse) && isset($aFetchResponse[0])) {
|
||||||
$oBodyStructure = $aFetchResponse[0]->GetFetchBodyStructure();
|
$oBodyStructure = $aFetchResponse[0]->GetFetchBodyStructure();
|
||||||
if ($oBodyStructure) {
|
if ($oBodyStructure) {
|
||||||
|
$iBodyTextLimit = $this->oImapClient->Settings->body_text_limit;
|
||||||
foreach ($oBodyStructure->GetHtmlAndPlainParts() as $oPart) {
|
foreach ($oBodyStructure->GetHtmlAndPlainParts() as $oPart) {
|
||||||
$sLine = FetchType::BODY_PEEK.'['.$oPart->PartID().']';
|
$sLine = FetchType::BODY_PEEK.'['.$oPart->PartID().']';
|
||||||
if (0 < $iBodyTextLimit && $iBodyTextLimit < $oPart->Size()) {
|
if (0 < $iBodyTextLimit && $iBodyTextLimit < $oPart->EstimatedSize()) {
|
||||||
$sLine .= "<0.{$iBodyTextLimit}>";
|
$sLine .= "<0.{$iBodyTextLimit}>";
|
||||||
}
|
}
|
||||||
$aFetchItems[] = $sLine;
|
$aFetchItems[] = $sLine;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue