More changes for #1003

This commit is contained in:
the-djmaze 2023-03-06 13:21:21 +01:00
parent 8c7fd77762
commit 206c8abdf5
2 changed files with 29 additions and 17 deletions

View file

@ -465,6 +465,29 @@ class Message implements \JsonSerializable
return $oMessage;
}
public function ETag(string $sClientHash) : string
{
return \md5('MessageHash/' . \implode('/', [
$this->sFolder,
$this->Uid,
\implode(',', $this->getFlags()),
// \implode(',', $this->aThreads),
$sClientHash
]));
}
// https://datatracker.ietf.org/doc/html/rfc5788#section-3.4.1
// Thunderbird $label1 is same as $Important?
// Thunderbird $label4 is same as $todo?
protected function getFlags() : array
{
return \array_unique(\str_replace(
['$readreceipt', '$replied', /* 'junk', 'nonjunk', '$queued', '$sent', 'sent'*/],
['$mdnsent', '\\answered',/* '$junk', '$notjunk', '$submitpending', '$submitted', '$submitted'*/],
$this->aFlagsLowerCase
));
}
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
@ -476,15 +499,6 @@ class Message implements \JsonSerializable
$this->aFlagsLowerCase
), true);
*/
// https://datatracker.ietf.org/doc/html/rfc5788#section-3.4.1
// Thunderbird $label1 is same as $Important?
// Thunderbird $label4 is same as $todo?
$aFlags = \array_unique(\str_replace(
['$readreceipt', '$replied', /* 'junk', 'nonjunk', '$queued', '$sent', 'sent'*/],
['$mdnsent', '\\answered',/* '$junk', '$notjunk', '$submitpending', '$submitted', '$submitted'*/],
$this->aFlagsLowerCase
));
$aAutocrypt = [];
if ($this->sAutocrypt) {
foreach (\explode(';', $this->sAutocrypt) as $entry) {
@ -527,7 +541,7 @@ class Message implements \JsonSerializable
'dkim' => $this->DKIM,
'dmarc' => $this->DMARC,
'flags' => $aFlags,
'flags' => $this->getFlags(),
'inReplyTo' => $this->InReplyTo,

View file

@ -406,15 +406,12 @@ trait Messages
{
$sRawKey = (string) $this->GetActionParam('RawKey', '');
$sFolder = '';
$iUid = 0;
$aValues = \json_decode(\MailSo\Base\Utils::UrlSafeBase64Decode($sRawKey), true);
if ($aValues && 2 <= \count($aValues)) {
$sFolder = (string) $aValues[0];
$iUid = (int) $aValues[1];
$this->verifyCacheByKey($sRawKey);
// $useThreads = !empty($aValues[2]);
// $accountHash = $aValues[3];
} else {
$sFolder = $this->GetActionParam('folder', '');
$iUid = (int) $this->GetActionParam('uid', 0);
@ -432,9 +429,10 @@ trait Messages
}
if ($oMessage) {
$ETag = $oMessage->ETag($this->ImapClient()->Hash());
$this->verifyCacheByKey($ETag);
$this->Plugins()->RunHook('filter.result-message', array($oMessage));
$this->cacheByKey($sRawKey);
$this->cacheByKey($ETag);
}
return $this->DefaultResponse($oMessage);