Remove UNSEEN on IMAP4rev2 deprecated SELECT/EXAMINE

This commit is contained in:
the-djmaze 2022-12-05 10:31:13 +01:00
parent 4a5bd9033f
commit a7f93ef864
3 changed files with 34 additions and 44 deletions

View file

@ -112,7 +112,7 @@ trait Folders
*
* https://datatracker.ietf.org/doc/html/rfc9051#section-6.3.11
*/
public function FolderStatus(string $sFolderName) : FolderInformation
public function FolderStatus(string $sFolderName, bool $bSelect = false) : FolderInformation
{
$aStatusItems = array(
FolderResponseStatus::MESSAGES,
@ -166,14 +166,31 @@ trait Folders
$oInfo->setStatusFromResponse($oResponse);
}
if ($bReselect) {
$this->selectOrExamineFolder($sFolderName, $bWritable, false);
// $this->oCurrentFolderInfo->UNSEEN = $oInfo->UNSEEN;
if ($bReselect || $bSelect) {
// Don't use FolderExamine, else PERMANENTFLAGS is empty in Dovecot
$oFolderInformation = $this->selectOrExamineFolder($sFolderName, $bSelect || $bWritable, false);
$oFolderInformation->MESSAGES = \max(0, $oFolderInformation->MESSAGES, $oInfo->MESSAGES);
// $oFolderInformation has the message sequence number of the first unseen message in the mailbox
// so we set it to the amount of unseen messages
$oFolderInformation->UNSEEN = \max(0, $oInfo->UNSEEN);
$oFolderInformation->UIDNEXT = \max(0, $oFolderInformation->UIDNEXT, $oInfo->UIDNEXT);
$oFolderInformation->UIDVALIDITY = \max(0, $oFolderInformation->UIDVALIDITY, $oInfo->UIDVALIDITY);
$oFolderInformation->HIGHESTMODSEQ = \max(0, $oInfo->HIGHESTMODSEQ);
$oFolderInformation->APPENDLIMIT = \max(0, $oFolderInformation->APPENDLIMIT, $oInfo->APPENDLIMIT);
$oFolderInformation->MAILBOXID = $oFolderInformation->MAILBOXID ?: $oInfo->MAILBOXID;
// $oFolderInformation->SIZE = \max($oFolderInformation->SIZE, $oInfo->SIZE);
// $oFolderInformation->RECENT = \max(0, $oFolderInformation->RECENT, $oInfo->RECENT);
return $oFolderInformation;
}
return $oInfo;
}
public function FolderStatusAndSelect(string $sFolderName) : FolderInformation
{
return $this->FolderStatus($sFolderName, true);
}
/**
* @throws \MailSo\RuntimeException
* @throws \MailSo\Net\Exceptions\*
@ -382,6 +399,9 @@ trait Folders
}
}
// IMAP4rev2 deprecated
$oResult->UNSEEN = null;
$this->oCurrentFolderInfo = $oResult;
return $oResult;

View file

@ -41,12 +41,6 @@ class FolderInformation implements \JsonSerializable
*/
public $PermanentFlags = array();
/**
* https://datatracker.ietf.org/doc/html/rfc3501#section-7.3.1
* @var int
*/
public $Exists = null;
function __construct(string $sFolderName, bool $bIsWritable)
{
$this->FolderName = $sFolderName;

View file

@ -17,53 +17,29 @@ namespace MailSo\Mail;
*/
class MessageCollection extends \MailSo\Base\Collection
{
/**
* @var string
*/
public $FolderHash = '';
public string $FolderHash = '';
/**
* @var int
* Amount of UIDs in this list (could be less then total messages when using threads)
*/
public $MessageResultCount = 0;
public int $MessageResultCount = 0;
/**
* @var string
*/
public $FolderName = '';
public string $FolderName = '';
/**
* @var int
*/
public $Offset = 0;
public int $Offset = 0;
/**
* @var int
*/
public $Limit = 0;
public int $Limit = 0;
/**
* @var string
*/
public $Search = '';
public string $Search = '';
/**
* @var int
*/
public $ThreadUid = 0;
public int $ThreadUid = 0;
// MailSo\Imap\FolderInformation
public $FolderInfo = null;
/**
* @var array
*/
public $NewMessages = array();
public array $NewMessages = array();
/**
* @var bool
*/
public $Filtered = false;
public bool $Filtered = false;
public function append($oMessage, bool $bToTop = false) : void
{