mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Improved IMAP4rev2 RFC9051 support
This commit is contained in:
parent
1cdbf2b944
commit
d3ad9dc115
|
@ -20,7 +20,7 @@ abstract class FolderResponseStatus
|
|||
{
|
||||
// rfc3501
|
||||
const MESSAGES = 'MESSAGES';
|
||||
const RECENT = 'RECENT'; // Obsolete in IMAP4rev2
|
||||
// const RECENT = 'RECENT'; // IMAP4rev2 deprecated
|
||||
const UIDNEXT = 'UIDNEXT';
|
||||
const UIDVALIDITY = 'UIDVALIDITY';
|
||||
const UNSEEN = 'UNSEEN';
|
||||
|
|
|
@ -20,7 +20,7 @@ abstract class FolderStatus
|
|||
{
|
||||
// rfc3501
|
||||
const MESSAGES = 'MESSAGES';
|
||||
const RECENT = 'RECENT'; // Obsolete in IMAP4rev2
|
||||
// const RECENT = 'RECENT'; // IMAP4rev2 deprecated
|
||||
const UIDNEXT = 'UIDNEXT';
|
||||
const UIDVALIDITY = 'UIDVALIDITY';
|
||||
const UNSEEN = 'UNSEEN';
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace MailSo\Imap\Enumerations;
|
|||
*/
|
||||
abstract class MessageFlag
|
||||
{
|
||||
const RECENT = '\\Recent';
|
||||
// const RECENT = '\\Recent'; // IMAP4rev2 deprecated
|
||||
const SEEN = '\\Seen';
|
||||
const DELETED = '\\Deleted';
|
||||
const FLAGGED = '\\Flagged';
|
||||
|
|
|
@ -442,6 +442,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
$aReturnParams = array();
|
||||
|
||||
if ($bIsSubscribeList) {
|
||||
// IMAP4rev2 deprecated
|
||||
$sCmd = 'LSUB';
|
||||
} else if ($this->IsSupported('LIST-EXTENDED')) {
|
||||
// RFC 5258
|
||||
|
@ -556,6 +557,9 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
throw new \MailSo\Base\Exceptions\InvalidArgumentException;
|
||||
}
|
||||
|
||||
/**
|
||||
* IMAP4rev2 SELECT/EXAMINE are now required to return an untagged LIST response.
|
||||
*/
|
||||
$this->oCurrentFolderInfo = $this->SendRequestGetResponse($bIsWritable ? 'SELECT' : 'EXAMINE',
|
||||
array($this->EscapeString($sFolderName)))
|
||||
->getCurrentFolderInformation($sFolderName, $bIsWritable);
|
||||
|
|
|
@ -33,7 +33,7 @@ trait Status
|
|||
/**
|
||||
* The number of messages with the \Recent flag set.
|
||||
* This response also occurs as a result of a SELECT or EXAMINE command.
|
||||
* Obsolete in IMAP4rev2
|
||||
* IMAP4rev2 deprecated.
|
||||
* @var int
|
||||
*/
|
||||
$RECENT,
|
||||
|
@ -55,8 +55,9 @@ trait Status
|
|||
|
||||
/**
|
||||
* The number of messages which do not have the \Seen flag set.
|
||||
* This response also occurs as a result of a SELECT or EXAMINE command,
|
||||
* This response also occurs as a result of a IMAP4rev1 SELECT or EXAMINE command,
|
||||
* but then it is the message sequence number of the first unseen message.
|
||||
* IMAP4rev2 deprecated on SELECT/EXAMINE.
|
||||
* @var int
|
||||
*/
|
||||
$UNSEEN,
|
||||
|
|
|
@ -665,7 +665,7 @@ class MailClient
|
|||
'MessageCount' => $iCount,
|
||||
'MessageUnseenCount' => $iUnseenCount,
|
||||
'UidNext' => $iUidNext,
|
||||
'Flags' => $aFlags,
|
||||
'MessageFlags' => $aFlags,
|
||||
'HighestModSeq' => $iHighestModSeq,
|
||||
'NewMessages' => 'INBOX' === $sFolderName && \MailSo\Config::$CheckNewMessages ?
|
||||
$this->getFolderNextMessageInformation($sFolderName, $iPrevUidNext, $iUidNext) : array()
|
||||
|
|
|
@ -31,7 +31,6 @@ class Message implements \JsonSerializable
|
|||
$iInternalTimeStampInUTC = 0,
|
||||
$iHeaderTimeStampInUTC = 0,
|
||||
$sHeaderDate = '',
|
||||
$aFlags = [],
|
||||
$aFlagsLowerCase = [],
|
||||
|
||||
/**
|
||||
|
@ -194,11 +193,6 @@ class Message implements \JsonSerializable
|
|||
return $this->sHeaderDate;
|
||||
}
|
||||
|
||||
public function Flags() : array
|
||||
{
|
||||
return $this->aFlags;
|
||||
}
|
||||
|
||||
public function FlagsLowerCase() : array
|
||||
{
|
||||
return $this->aFlagsLowerCase;
|
||||
|
@ -317,8 +311,7 @@ class Message implements \JsonSerializable
|
|||
$this->sFolder = $sFolder;
|
||||
$this->iUid = (int) $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
|
||||
$this->iSize = (int) $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::RFC822_SIZE);
|
||||
$this->aFlags = \is_array($aFlags) ? $aFlags : array();
|
||||
$this->aFlagsLowerCase = \array_map('strtolower', $this->aFlags);
|
||||
$this->aFlagsLowerCase = \array_map('strtolower', $aFlags ?: []);
|
||||
|
||||
$this->iInternalTimeStampInUTC =
|
||||
\MailSo\Base\DateTimeHelper::ParseInternalDateString($sInternalDate);
|
||||
|
@ -692,7 +685,11 @@ class Message implements \JsonSerializable
|
|||
'IsSeen' => \in_array('\\seen', $this->aFlagsLowerCase),
|
||||
'IsFlagged' => \in_array('\\flagged', $this->aFlagsLowerCase),
|
||||
'IsAnswered' => \in_array('\\answered', $this->aFlagsLowerCase),
|
||||
'IsDeleted' => \in_array('\\deleted', $this->aFlagsLowerCase)
|
||||
'IsDeleted' => \in_array('\\deleted', $this->aFlagsLowerCase),
|
||||
'IsForwarded' => \in_array(\strtolower('$Forwarded'), $this->aFlagsLowerCase),
|
||||
'IsReadReceipt' => \in_array(\strtolower('$MDNSent'), $this->aFlagsLowerCase),
|
||||
'IsJunk' => !\in_array(\strtolower('$NonJunk'), $this->aFlagsLowerCase) && \in_array(\strtolower('$Junk'), $this->aFlagsLowerCase),
|
||||
'IsPhishing' => \in_array(\strtolower('$Phishing'), $this->aFlagsLowerCase)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -363,8 +363,7 @@ trait Folders
|
|||
$aInboxInformation = $this->MailClient()->FolderInformation(
|
||||
$sFolder, $iPrevUidNext, $aFlagsUids
|
||||
);
|
||||
|
||||
foreach ($aInboxInformation['Flags'] as $iUid => $aFlags)
|
||||
foreach ($aInboxInformation['MessageFlags'] as $iUid => $aFlags)
|
||||
{
|
||||
$aLowerFlags = \array_map('strtolower', $aFlags);
|
||||
$aInboxInformation['Flags'][$iUid] = array(
|
||||
|
@ -374,11 +373,13 @@ trait Folders
|
|||
'IsFlagged' => \in_array('\\flagged', $aLowerFlags),
|
||||
'IsAnswered' => \in_array('\\answered', $aLowerFlags),
|
||||
'IsDeleted' => \in_array('\\deleted', $aLowerFlags),
|
||||
'IsForwarded' => $sForwardedFlag && \in_array(\strtolower($sForwardedFlag), $aLowerFlags),
|
||||
'IsReadReceipt' => $sReadReceiptFlag && \in_array(\strtolower($sReadReceiptFlag), $aLowerFlags)
|
||||
'IsForwarded' => \in_array(\strtolower('$Forwarded'), $aLowerFlags) || ($sForwardedFlag && \in_array(\strtolower($sForwardedFlag), $aLowerFlags)),
|
||||
'IsReadReceipt' => \in_array(\strtolower('$MDNSent'), $aLowerFlags) || ($sReadReceiptFlag && \in_array(\strtolower($sReadReceiptFlag), $aLowerFlags)),
|
||||
'IsJunk' => !\in_array(\strtolower('$NonJunk'), $aLowerFlags) && \in_array(\strtolower('$Junk'), $aLowerFlags),
|
||||
'IsPhishing' => \in_array(\strtolower('$Phishing'), $aLowerFlags)
|
||||
);
|
||||
}
|
||||
$aInboxInformation['Flags'] = \array_values($aInboxInformation['Flags']);
|
||||
$aInboxInformation['Flags'] = \array_values($aInboxInformation['MessageFlags']);
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue