mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 00:17:03 +03:00
Speedup IMAP FETCH response
This commit is contained in:
parent
58f98cd69d
commit
ab6b9bb412
2 changed files with 10 additions and 34 deletions
|
|
@ -157,43 +157,19 @@ class FetchResponse
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function findFetchUidAndSize(array $aList) : bool
|
public static function isValidImapResponse(Response $oImapResponse) : bool
|
||||||
{
|
{
|
||||||
$bUid = false;
|
return
|
||||||
$bSize = false;
|
true !== $oImapResponse->IsStatusResponse
|
||||||
foreach ($aList as $mItem)
|
|
||||||
{
|
|
||||||
if (Enumerations\FetchType::UID === $mItem)
|
|
||||||
{
|
|
||||||
$bUid = true;
|
|
||||||
}
|
|
||||||
else if (Enumerations\FetchType::RFC822_SIZE === $mItem)
|
|
||||||
{
|
|
||||||
$bSize = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $bUid && $bSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function IsValidFetchImapResponse(Response $oImapResponse) : bool
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
$oImapResponse
|
|
||||||
&& true !== $oImapResponse->IsStatusResponse
|
|
||||||
&& Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType
|
&& Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType
|
||||||
&& 3 < count($oImapResponse->ResponseList) && 'FETCH' === $oImapResponse->ResponseList[2]
|
&& 3 < \count($oImapResponse->ResponseList) && 'FETCH' === $oImapResponse->ResponseList[2]
|
||||||
&& is_array($oImapResponse->ResponseList[3])
|
&& \is_array($oImapResponse->ResponseList[3]);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function IsNotEmptyFetchImapResponse(Response $oImapResponse) : bool
|
public static function hasUidAndSize(Response $oImapResponse) : bool
|
||||||
{
|
{
|
||||||
return (
|
return \in_array(Enumerations\FetchType::UID, $oImapResponse->ResponseList[3])
|
||||||
$oImapResponse
|
&& \in_array(Enumerations\FetchType::RFC822_SIZE, $oImapResponse->ResponseList[3]);
|
||||||
&& self::IsValidFetchImapResponse($oImapResponse)
|
|
||||||
&& isset($oImapResponse->ResponseList[3])
|
|
||||||
&& self::findFetchUidAndSize($oImapResponse->ResponseList[3])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -883,8 +883,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
$this->SendRequest($bIndexIsUid ? 'UID FETCH' : 'FETCH', $aParams);
|
$this->SendRequest($bIndexIsUid ? 'UID FETCH' : 'FETCH', $aParams);
|
||||||
foreach ($this->yieldUntaggedResponses() as $oResponse) {
|
foreach ($this->yieldUntaggedResponses() as $oResponse) {
|
||||||
if (FetchResponse::IsValidFetchImapResponse($oResponse)) {
|
if (FetchResponse::isValidImapResponse($oResponse)) {
|
||||||
if (FetchResponse::IsNotEmptyFetchImapResponse($oResponse)) {
|
if (FetchResponse::hasUidAndSize($oResponse)) {
|
||||||
$aReturn[] = new FetchResponse($oResponse);
|
$aReturn[] = new FetchResponse($oResponse);
|
||||||
} else if ($this->oLogger) {
|
} else if ($this->oLogger) {
|
||||||
$this->oLogger->Write('Skipped Imap Response! ['.$oResponse->ToLine().']', \MailSo\Log\Enumerations\Type::NOTICE);
|
$this->oLogger->Write('Skipped Imap Response! ['.$oResponse->ToLine().']', \MailSo\Log\Enumerations\Type::NOTICE);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue