diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Folder.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Folder.php index 4030938aae..bb109d58ee 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Folder.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Folder.php @@ -148,9 +148,9 @@ public function Role() : ?string 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] @@ -163,7 +163,7 @@ public function jsonSerialize() 'totalEmails' => (int) $this->MESSAGES, 'unreadEmails' => (int) $this->UNSEEN, 'uidNext' => (int) $this->UIDNEXT, -// 'etag' => $this->Hash($this->ImapClient()->Hash()) +// 'etag' => $this->ETag($this->ImapClient()->Hash()) ); } */ diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Traits/Status.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Traits/Status.php index 1f909f3fba..1058e55891 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Traits/Status.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Traits/Status.php @@ -26,78 +26,74 @@ trait Status public bool $hasStatus = false; - public - /** - * The number of messages in the mailbox. - * This response is named EXISTS as a result of a SELECT or EXAMINE command. - * @var int - */ - $MESSAGES, - - /** - * The number of messages with the \Recent flag set. - * This response also occurs as a result of a SELECT or EXAMINE command. - * IMAP4rev2 deprecated. - * @var int - */ - $RECENT, - - /** - * The next unique identifier value of the mailbox. - * A 32-bit value - * This response also occurs as a result of a SELECT or EXAMINE command. - * @var int - */ - $UIDNEXT, - - /** - * The unique identifier validity value of the mailbox. - * This response also occurs as a result of a SELECT or EXAMINE command. - * @var int - */ - $UIDVALIDITY, - - /** - * 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, - * but then it is the message sequence number of the first unseen message. - * IMAP4rev2 deprecated on SELECT/EXAMINE. - * @var int - */ - $UNSEEN, - - /** - * RFC 4551 - * The highest mod-sequence value of all messages in the mailbox. - * This response also occurs as a result of a SELECT or EXAMINE command. - * @var int 1*DIGIT Positive unsigned 64-bit integer - */ - $HIGHESTMODSEQ, - - /** - * RFC 7889 - * Message upload size limit. - * @var int - */ - $APPENDLIMIT, - - /** - * RFC 8474 - * A server-allocated unique identifier for the mailbox. - * This response also occurs as a result of a CREATE, SELECT or EXAMINE command. - * @var string - */ - $MAILBOXID, - - /** - * RFC 9051 - * The total size of the mailbox in octets. - * @var int - */ - $SIZE; + /** + * The number of messages in the mailbox. + * This response is named EXISTS as a result of a SELECT or EXAMINE command. + */ + public ?int $MESSAGES = null; + + /** + * The number of messages with the \Recent flag set. + * This response also occurs as a result of a SELECT or EXAMINE command. + * IMAP4rev2 deprecated. + */ + public ?int $RECENT = null; + + /** + * The next unique identifier value of the mailbox. + * A 32-bit value + * This response also occurs as a result of a SELECT or EXAMINE command. + */ + public ?int $UIDNEXT = null; + + /** + * The unique identifier validity value of the mailbox. + * This response also occurs as a result of a SELECT or EXAMINE command. + */ + public ?int $UIDVALIDITY = null; + + /** + * 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, + * but then it is the message sequence number of the first unseen message. + * IMAP4rev2 deprecated on SELECT/EXAMINE. + */ + public ?int $UNSEEN = null; + + /** + * RFC 4551 + * The highest mod-sequence value of all messages in the mailbox. + * This response also occurs as a result of a SELECT or EXAMINE command. + * 1*DIGIT Positive unsigned 64-bit integer + */ + public ?int $HIGHESTMODSEQ = null; + + /** + * RFC 7889 + * Message upload size limit. + */ + public ?int $APPENDLIMIT = null; + + /** + * RFC 8474 + * A server-allocated unique identifier for the mailbox. + * This response also occurs as a result of a CREATE, SELECT or EXAMINE command. + */ + public ?string $MAILBOXID = null; + + /** + * RFC 9051 + * The total size of the mailbox in octets. + */ + public ?int $SIZE = null; 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)) { return null; } @@ -106,13 +102,13 @@ public function getETag(string $sClientHash) : ?string $this->MESSAGES, $this->UIDNEXT, $this->UIDVALIDITY, -// $this->UNSEEN, // undefined when SELECT/EXAMINE + $this->UNSEEN, $this->HIGHESTMODSEQ, $sClientHash ])); } - private function setStatus(string $name, $value) : bool + private function setStatusItem(string $name, $value) : bool { if ('EXISTS' === $name) { $name = 'MESSAGES'; @@ -150,7 +146,7 @@ public function setStatusFromResponse(\MailSo\Imap\Response $oResponse) : bool // OK untagged responses if (\is_array($oResponse->OptionalResponse)) { 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 @@ public function setStatusFromResponse(\MailSo\Imap\Response $oResponse) : bool && \is_array($oResponse->ResponseList[3])) { $c = \count($oResponse->ResponseList[3]); for ($i = 0; $i < $c; $i += 2) { - $bResult |= $this->setStatus( + $bResult |= $this->setStatusItem( $oResponse->ResponseList[3][$i], $oResponse->ResponseList[3][$i+1] ); @@ -173,7 +169,7 @@ public function setStatusFromResponse(\MailSo\Imap\Response $oResponse) : bool else if (\is_numeric($oResponse->ResponseList[1]) && \is_string($oResponse->ResponseList[2])) { // UNSEEN deprecated in IMAP4rev2 if ('UNSEEN' !== $oResponse->ResponseList[2]) { - $bResult |= $this->setStatus($oResponse->ResponseList[2], $oResponse->ResponseList[1]); + $bResult |= $this->setStatusItem($oResponse->ResponseList[2], $oResponse->ResponseList[1]); } } } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Response.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Response.php index 9590565dde..21063a73e0 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Response.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Response.php @@ -191,7 +191,7 @@ private function responseObject($mResponse, string $sParent = '') if ($mResponse instanceof \MailSo\Imap\Folder) { $aResult = $mResponse->jsonSerialize(); - $sHash = $mResponse->Hash($this->ImapClient()->Hash()); + $sHash = $mResponse->ETag($this->ImapClient()->Hash()); if ($sHash) { $aResult['etag'] = $sHash; }