INDEX should never been a FetchType as it's not part of any RFC
This commit is contained in:
djmaze 2022-01-08 19:39:59 +01:00
parent 29fa090795
commit 6c6e73f448
4 changed files with 15 additions and 13 deletions

View file

@ -42,7 +42,6 @@ trait Messages
$this->aFetchCallbacks = array();
try {
$aFetchItems = array(
FetchType::INDEX,
FetchType::UID,
FetchType::RFC822_SIZE
);
@ -50,14 +49,19 @@ trait Messages
{
switch ($mFetchKey)
{
case FetchType::INDEX:
case FetchType::UID:
case FetchType::RFC822_SIZE:
// Already defined by default
break;
// Macro's
case FetchType::FULL:
$aFetchItems[] = FetchType::BODY;
// Falls through
case FetchType::ALL:
$aFetchItems[] = FetchType::ENVELOPE;
// Falls through
case FetchType::FAST:
$aFetchItems[] = FetchType::FLAGS;
$aFetchItems[] = FetchType::INTERNALDATE;
break;

View file

@ -18,7 +18,13 @@ namespace MailSo\Imap\Enumerations;
*/
abstract class FetchType
{
// Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE)
const FAST = 'FAST';
// Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE)
const ALL = 'ALL';
// Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)
const FULL = 'FULL';
const BODY = 'BODY';
const BODY_PEEK = 'BODY.PEEK';
const BODY_HEADER = 'BODY[HEADER]';
@ -32,7 +38,6 @@ abstract class FetchType
const RFC822_SIZE = 'RFC822.SIZE';
const RFC822_TEXT = 'RFC822.TEXT';
const UID = 'UID';
const INDEX = 'INDEX';
// RFC 3516
const BINARY = 'BINARY';
const BINARY_PEEK = 'BINARY.PEEK';

View file

@ -105,10 +105,6 @@ class FetchResponse
*/
public function GetFetchValue(string $sFetchItemName)
{
if (Enumerations\FetchType::INDEX === $sFetchItemName) {
return $this->oImapResponse->ResponseList[1];
}
if (isset($this->oImapResponse->ResponseList[3]) && \is_array($this->oImapResponse->ResponseList[3])) {
$bNextIsValue = false;
foreach ($this->oImapResponse->ResponseList[3] as $mItem) {

View file

@ -157,7 +157,6 @@ class MailClient
$oMessage = null;
$aFetchItems = array(
FetchType::INDEX,
FetchType::UID,
FetchType::RFC822_SIZE,
FetchType::INTERNALDATE,
@ -477,7 +476,6 @@ class MailClient
$this->oImapClient->FolderExamine($sFolderName);
$aFetchResponse = $this->oImapClient->Fetch(array(
FetchType::INDEX,
FetchType::UID,
FetchType::FLAGS,
FetchType::BuildBodyCustomHeaderRequest(array(
@ -533,7 +531,6 @@ class MailClient
$this->oImapClient->FolderExamine($sFolderName);
$aFetchResponse = $this->oImapClient->Fetch(array(
FetchType::INDEX,
FetchType::UID,
FetchType::FLAGS
), (string) $oRange, $oRange->UID);
@ -667,7 +664,6 @@ class MailClient
if (\count($oRange))
{
$aFetchResponse = $this->oImapClient->Fetch(array(
FetchType::INDEX,
FetchType::UID,
FetchType::RFC822_SIZE,
FetchType::INTERNALDATE,
@ -679,9 +675,10 @@ class MailClient
if (\count($aFetchResponse))
{
$aCollection = \array_fill_keys($oRange->getArrayCopy(), null);
$sFetchType = $oRange->UID ? FetchType::UID : FetchType::INDEX;
foreach ($aFetchResponse as /* @var $oFetchResponseItem \MailSo\Imap\FetchResponse */ $oFetchResponseItem) {
$id = $oFetchResponseItem->GetFetchValue($sFetchType);
$id = $oRange->UID
? $oFetchResponseItem->GetFetchValue(FetchType::UID)
: $this->oImapResponse->ResponseList[1];
$aCollection[$id] = Message::NewFetchResponseInstance($oMessageCollection->FolderName, $oFetchResponseItem);
}
$oMessageCollection->exchangeArray(\array_values(\array_filter($aCollection)));