Some changes for #419 flags

This commit is contained in:
the-djmaze 2022-05-29 10:12:49 +02:00
parent 5f6ea3cf29
commit 135406ebfe
5 changed files with 37 additions and 16 deletions

View file

@ -15,7 +15,7 @@ namespace MailSo\Imap;
* @category MailSo
* @package Imap
*/
class FolderInformation
class FolderInformation implements \JsonSerializable
{
use Traits\Status;
@ -36,6 +36,7 @@ class FolderInformation
/**
* @var array
* NOTE: Empty when FolderExamine is used
*/
public $PermanentFlags = array();
@ -57,4 +58,23 @@ class FolderInformation
\in_array($sFlag, $this->PermanentFlags) ||
\in_array($sFlag, $this->Flags);
}
public function jsonSerialize()
{
return array(
'Name' => $this->FolderName,
'Flags' => $this->Flags,
'PermanentFlags' => $this->PermanentFlags,
/*
'Messages' => $this->MESSAGES,
'Unseen' => $this->UNSEEN,
'Recent' => $this->RECENT,
'UidNext' => $this->UIDNEXT,
'UidValidity' => $this->UIDVALIDITY,
'Highestmodseq' => $this->HIGHESTMODSEQ,
'Appendlimit' => $this->APPENDLIMIT,
'Mailboxid' => $this->MAILBOXID,
*/
);
}
}

View file

@ -228,6 +228,7 @@ class Folder implements \JsonSerializable
'Selectable' => $this->IsSelectable(),
'Flags' => $this->FlagsLowerCase(),
// 'Extended' => $aExtended,
// 'PermanentFlags' => $this->oImapFolder->PermanentFlags,
'Metadata' => $this->oImapFolder->Metadata()
);
}

View file

@ -521,21 +521,19 @@ class MailClient
*/
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, SequenceSet $oRange = null) : array
{
$aFlags = array();
list($iCount, $iUnseenCount, $iUidNext, $iHighestModSeq, $iAppendLimit, $sMailboxId) = $this->initFolderValues($sFolderName);
if ($oRange && \count($oRange))
{
$this->oImapClient->FolderExamine($sFolderName);
$aFlags = array();
if ($oRange && \count($oRange)) {
$oInfo = $this->oImapClient->FolderExamine($sFolderName);
// $oInfo->PermanentFlags
$aFetchResponse = $this->oImapClient->Fetch(array(
FetchType::UID,
FetchType::FLAGS
), (string) $oRange, $oRange->UID);
foreach ($aFetchResponse as $oFetchResponse)
{
foreach ($aFetchResponse as $oFetchResponse) {
$iUid = (int) $oFetchResponse->GetFetchValue(FetchType::UID);
$aLowerFlags = \array_map('strtolower', $oFetchResponse->GetFetchValue(FetchType::FLAGS));
$aFlags[] = array(
@ -830,15 +828,19 @@ class MailClient
list($iMessageRealCount, $iMessageUnseenCount, $iUidNext, $iHighestModSeq) = $this->initFolderValues($oParams->sFolderName);
$this->oImapClient->FolderExamine($oParams->sFolderName);
// Don't use FolderExamine, else PERMANENTFLAGS is empty
$oInfo = $this->oImapClient->FolderSelect($oParams->sFolderName);
$oMessageCollection = new MessageCollection;
$oMessageCollection->FolderName = $oParams->sFolderName;
$oMessageCollection->FolderInfo = $oInfo;
$oMessageCollection->Offset = $oParams->iOffset;
$oMessageCollection->Limit = $oParams->iLimit;
$oMessageCollection->Search = $sSearch;
$oMessageCollection->ThreadUid = $oParams->iThreadUid;
$oMessageCollection->Filtered = '' !== \MailSo\Config::$MessageListPermanentFilter;
$oMessageCollection->MessageCount = $iMessageRealCount;
$oMessageCollection->MessageUnseenCount = $iMessageUnseenCount;
$aUids = array();
$aAllThreads = [];
@ -934,8 +936,6 @@ class MailClient
}
}
$oMessageCollection->MessageCount = $iMessageRealCount;
$oMessageCollection->MessageUnseenCount = $iMessageUnseenCount;
$oMessageCollection->MessageResultCount = \count($aUids);
if (\count($aUids))
@ -954,9 +954,6 @@ class MailClient
', limit:'.\MailSo\Config::$MessageListCountLimitTrigger.')');
}
$oMessageCollection->MessageCount = $iMessageRealCount;
$oMessageCollection->MessageUnseenCount = $iMessageUnseenCount;
if (\strlen($sSearch))
{
$aUids = $this->GetUids($oParams->oCacher, $sSearch,

View file

@ -67,6 +67,9 @@ class MessageCollection extends \MailSo\Base\Collection
*/
public $ThreadUid = 0;
// MailSo\Imap\FolderInformation
public $FolderInfo = null;
/**
* @var array
*/
@ -97,6 +100,7 @@ class MessageCollection extends \MailSo\Base\Collection
'MessageResultCount' => $this->MessageResultCount,
'Folder' => $this->FolderName,
'FolderHash' => $this->FolderHash,
'FolderInfo' => $this->FolderInfo,
'UidNext' => $this->UidNext,
'ThreadUid' => $this->ThreadUid,
'NewMessages' => $this->NewMessages,

View file

@ -426,13 +426,12 @@ trait Folders
);
$aInboxInformation['Flags'] = $aInboxInformation['MessagesFlags'];
unset($aInboxInformation['MessagesFlags']);
return $this->DefaultResponse(__FUNCTION__, $aInboxInformation);
}
catch (\Throwable $oException)
{
throw new ClientException(Notifications::MailServerError, $oException);
}
return $this->DefaultResponse(__FUNCTION__, $aInboxInformation);
}
/**