mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Use UNSEEN in folder ETag #1003
This commit is contained in:
parent
24cf17f68b
commit
b7963ebfa0
3 changed files with 66 additions and 70 deletions
|
|
@ -148,9 +148,9 @@ class Folder implements \JsonSerializable
|
||||||
return $role ? \ltrim($role, '\\') : null;
|
return $role ? \ltrim($role, '\\') : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Hash(string $sClientHash) : ?string
|
public function ETag(string $sClientHash) : ?string
|
||||||
{
|
{
|
||||||
return $this->getETag($sClientHash);
|
return $this->Selectable() ? $this->getETag($sClientHash) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[\ReturnTypeWillChange]
|
#[\ReturnTypeWillChange]
|
||||||
|
|
@ -163,7 +163,7 @@ class Folder implements \JsonSerializable
|
||||||
'totalEmails' => (int) $this->MESSAGES,
|
'totalEmails' => (int) $this->MESSAGES,
|
||||||
'unreadEmails' => (int) $this->UNSEEN,
|
'unreadEmails' => (int) $this->UNSEEN,
|
||||||
'uidNext' => (int) $this->UIDNEXT,
|
'uidNext' => (int) $this->UIDNEXT,
|
||||||
// 'etag' => $this->Hash($this->ImapClient()->Hash())
|
// 'etag' => $this->ETag($this->ImapClient()->Hash())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -26,78 +26,74 @@ trait Status
|
||||||
|
|
||||||
public bool $hasStatus = false;
|
public bool $hasStatus = false;
|
||||||
|
|
||||||
public
|
|
||||||
/**
|
/**
|
||||||
* The number of messages in the mailbox.
|
* The number of messages in the mailbox.
|
||||||
* This response is named EXISTS as a result of a SELECT or EXAMINE command.
|
* This response is named EXISTS as a result of a SELECT or EXAMINE command.
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
$MESSAGES,
|
public ?int $MESSAGES = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of messages with the \Recent flag set.
|
* The number of messages with the \Recent flag set.
|
||||||
* This response also occurs as a result of a SELECT or EXAMINE command.
|
* This response also occurs as a result of a SELECT or EXAMINE command.
|
||||||
* IMAP4rev2 deprecated.
|
* IMAP4rev2 deprecated.
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
$RECENT,
|
public ?int $RECENT = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The next unique identifier value of the mailbox.
|
* The next unique identifier value of the mailbox.
|
||||||
* A 32-bit value
|
* A 32-bit value
|
||||||
* This response also occurs as a result of a SELECT or EXAMINE command.
|
* This response also occurs as a result of a SELECT or EXAMINE command.
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
$UIDNEXT,
|
public ?int $UIDNEXT = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The unique identifier validity value of the mailbox.
|
* The unique identifier validity value of the mailbox.
|
||||||
* This response also occurs as a result of a SELECT or EXAMINE command.
|
* This response also occurs as a result of a SELECT or EXAMINE command.
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
$UIDVALIDITY,
|
public ?int $UIDVALIDITY = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of messages which do not have the \Seen flag set.
|
* The number of messages which do not have the \Seen flag set.
|
||||||
* This response also occurs as a result of a IMAP4rev1 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.
|
* but then it is the message sequence number of the first unseen message.
|
||||||
* IMAP4rev2 deprecated on SELECT/EXAMINE.
|
* IMAP4rev2 deprecated on SELECT/EXAMINE.
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
$UNSEEN,
|
public ?int $UNSEEN = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RFC 4551
|
* RFC 4551
|
||||||
* The highest mod-sequence value of all messages in the mailbox.
|
* The highest mod-sequence value of all messages in the mailbox.
|
||||||
* This response also occurs as a result of a SELECT or EXAMINE command.
|
* This response also occurs as a result of a SELECT or EXAMINE command.
|
||||||
* @var int 1*DIGIT Positive unsigned 64-bit integer
|
* 1*DIGIT Positive unsigned 64-bit integer
|
||||||
*/
|
*/
|
||||||
$HIGHESTMODSEQ,
|
public ?int $HIGHESTMODSEQ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RFC 7889
|
* RFC 7889
|
||||||
* Message upload size limit.
|
* Message upload size limit.
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
$APPENDLIMIT,
|
public ?int $APPENDLIMIT = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RFC 8474
|
* RFC 8474
|
||||||
* A server-allocated unique identifier for the mailbox.
|
* A server-allocated unique identifier for the mailbox.
|
||||||
* This response also occurs as a result of a CREATE, SELECT or EXAMINE command.
|
* This response also occurs as a result of a CREATE, SELECT or EXAMINE command.
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
$MAILBOXID,
|
public ?string $MAILBOXID = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RFC 9051
|
* RFC 9051
|
||||||
* The total size of the mailbox in octets.
|
* The total size of the mailbox in octets.
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
$SIZE;
|
public ?int $SIZE = null;
|
||||||
|
|
||||||
public function getETag(string $sClientHash) : ?string
|
public function getETag(string $sClientHash) : ?string
|
||||||
{
|
{
|
||||||
|
if (!$this->hasStatus) {
|
||||||
|
// UNSEEN undefined when only SELECT/EXAMINE is used
|
||||||
|
\error_log("STATUS missing " . \print_r($this,true));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!isset($this->MESSAGES, $this->UIDNEXT)) {
|
if (!isset($this->MESSAGES, $this->UIDNEXT)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -106,13 +102,13 @@ trait Status
|
||||||
$this->MESSAGES,
|
$this->MESSAGES,
|
||||||
$this->UIDNEXT,
|
$this->UIDNEXT,
|
||||||
$this->UIDVALIDITY,
|
$this->UIDVALIDITY,
|
||||||
// $this->UNSEEN, // undefined when SELECT/EXAMINE
|
$this->UNSEEN,
|
||||||
$this->HIGHESTMODSEQ,
|
$this->HIGHESTMODSEQ,
|
||||||
$sClientHash
|
$sClientHash
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setStatus(string $name, $value) : bool
|
private function setStatusItem(string $name, $value) : bool
|
||||||
{
|
{
|
||||||
if ('EXISTS' === $name) {
|
if ('EXISTS' === $name) {
|
||||||
$name = 'MESSAGES';
|
$name = 'MESSAGES';
|
||||||
|
|
@ -150,7 +146,7 @@ trait Status
|
||||||
// OK untagged responses
|
// OK untagged responses
|
||||||
if (\is_array($oResponse->OptionalResponse)) {
|
if (\is_array($oResponse->OptionalResponse)) {
|
||||||
if (\count($oResponse->OptionalResponse) > 1) {
|
if (\count($oResponse->OptionalResponse) > 1) {
|
||||||
$bResult = $this->setStatus($oResponse->OptionalResponse[0], $oResponse->OptionalResponse[1]);
|
$bResult = $this->setStatusItem($oResponse->OptionalResponse[0], $oResponse->OptionalResponse[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +158,7 @@ trait Status
|
||||||
&& \is_array($oResponse->ResponseList[3])) {
|
&& \is_array($oResponse->ResponseList[3])) {
|
||||||
$c = \count($oResponse->ResponseList[3]);
|
$c = \count($oResponse->ResponseList[3]);
|
||||||
for ($i = 0; $i < $c; $i += 2) {
|
for ($i = 0; $i < $c; $i += 2) {
|
||||||
$bResult |= $this->setStatus(
|
$bResult |= $this->setStatusItem(
|
||||||
$oResponse->ResponseList[3][$i],
|
$oResponse->ResponseList[3][$i],
|
||||||
$oResponse->ResponseList[3][$i+1]
|
$oResponse->ResponseList[3][$i+1]
|
||||||
);
|
);
|
||||||
|
|
@ -173,7 +169,7 @@ trait Status
|
||||||
else if (\is_numeric($oResponse->ResponseList[1]) && \is_string($oResponse->ResponseList[2])) {
|
else if (\is_numeric($oResponse->ResponseList[1]) && \is_string($oResponse->ResponseList[2])) {
|
||||||
// UNSEEN deprecated in IMAP4rev2
|
// UNSEEN deprecated in IMAP4rev2
|
||||||
if ('UNSEEN' !== $oResponse->ResponseList[2]) {
|
if ('UNSEEN' !== $oResponse->ResponseList[2]) {
|
||||||
$bResult |= $this->setStatus($oResponse->ResponseList[2], $oResponse->ResponseList[1]);
|
$bResult |= $this->setStatusItem($oResponse->ResponseList[2], $oResponse->ResponseList[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ trait Response
|
||||||
if ($mResponse instanceof \MailSo\Imap\Folder) {
|
if ($mResponse instanceof \MailSo\Imap\Folder) {
|
||||||
$aResult = $mResponse->jsonSerialize();
|
$aResult = $mResponse->jsonSerialize();
|
||||||
|
|
||||||
$sHash = $mResponse->Hash($this->ImapClient()->Hash());
|
$sHash = $mResponse->ETag($this->ImapClient()->Hash());
|
||||||
if ($sHash) {
|
if ($sHash) {
|
||||||
$aResult['etag'] = $sHash;
|
$aResult['etag'] = $sHash;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue