Support RFC5258 to prevent LSUB roundtrip

This commit is contained in:
djmaze 2021-10-26 15:30:51 +02:00
parent 934431c6be
commit f992a06b63
4 changed files with 14 additions and 7 deletions

View file

@ -473,6 +473,11 @@ class ImapClient extends \MailSo\Net\NetClient
else
{
$bUseListStatus = false;
// RFC5258
if ($this->IsSupported('LIST-EXTENDED')) {
$aParameters[] = 'RETURN';
$aParameters[] = array('SUBSCRIBED'/*,'CHILDREN'*/);
}
}
$aReturn = $this->SendRequestGetResponse($sCmd, $aParameters)->getFoldersResult($sCmd, $bUseListStatus);

View file

@ -68,7 +68,7 @@ class Folder implements \JsonSerializable
$this->sParentFullNameRaw = \implode($this->oImapFolder->Delimiter(), $aNames);
}
$this->bSubscribed = $bSubscribed;
$this->bSubscribed = $bSubscribed || \in_array('\\subscribed', $oImapFolder->FlagsLowerCase());
$this->bExists = $bExists;
}

View file

@ -1915,8 +1915,10 @@ class MailClient
public function Folders(string $sParent = '', string $sListPattern = '*', bool $bUseListSubscribeStatus = true, int $iOptimizationLimit = 0) : ?FolderCollection
{
$aImapSubscribedFoldersHelper = null;
if ($bUseListSubscribeStatus)
{
if ($this->oImapClient->IsSupported('LIST-EXTENDED')) {
$bUseListSubscribeStatus = false;
} else if ($bUseListSubscribeStatus) {
//\error_log('RFC5258 not supported, using LSUB');
try
{
$aSubscribedFolders = $this->oImapClient->FolderSubscribeList($sParent, $sListPattern);
@ -1928,7 +1930,7 @@ class MailClient
}
catch (\Throwable $oException)
{
unset($oException);
\error_log('ERROR FolderSubscribeList: ' . $oException->getMessage());
}
}
@ -1941,8 +1943,8 @@ class MailClient
foreach ($aFolders as /* @var $oImapFolder \MailSo\Imap\Folder */ $oImapFolder)
{
$aMailFoldersHelper[] = new Folder($oImapFolder,
(null === $aImapSubscribedFoldersHelper || \in_array($oImapFolder->FullNameRaw(), $aImapSubscribedFoldersHelper)) ||
$oImapFolder->IsInbox()
($bUseListSubscribeStatus && (null === $aImapSubscribedFoldersHelper || \in_array($oImapFolder->FullNameRaw(), $aImapSubscribedFoldersHelper)))
|| $oImapFolder->IsInbox()
);
}

View file

@ -193,7 +193,7 @@ trait Folders
try
{
$this->MailClient()->FolderSubscribe($sFolderFullNameRaw, !!$bSubscribe);
$this->MailClient()->FolderSubscribe($sFolderFullNameRaw, $bSubscribe);
}
catch (\Throwable $oException)
{