Bugfix: ask/send readReceipt was broken

This commit is contained in:
the-djmaze 2024-01-23 10:20:54 +01:00
parent 61c533a1a6
commit 5e35e39012
4 changed files with 27 additions and 28 deletions

View file

@ -155,10 +155,10 @@ export class MailMessageView extends AbstractViewRight {
: ''
).join(' '),
askReadReceipt: () =>
(MessagelistUserStore.isDraftFolder() || MessagelistUserStore.isSentFolder())
&& currentMessage()?.readReceipt()
&& currentMessage()?.flags().includes('$mdnsent'),
askReadReceipt: () => currentMessage()?.readReceipt()
&& !(MessagelistUserStore.isDraftFolder() || MessagelistUserStore.isSentFolder())
&& !currentMessage()?.flags().includes('$mdnsent')
&& !currentMessage()?.flags().includes('\\answered'),
listAttachments: () => currentMessage()?.attachments()
.filter(item => SettingsUserStore.listInlineAttachments() || !item.isLinked()),

View file

@ -197,10 +197,23 @@ class Message implements \JsonSerializable
// $oMessage->sDeliveryReceipt = \trim($oHeaders->ValueByName(MimeHeader::RETURN_RECEIPT_TO));
// Read Receipt
$oMessage->ReadReceipt = \trim($oHeaders->ValueByName(MimeHeader::DISPOSITION_NOTIFICATION_TO));
if (empty($oMessage->ReadReceipt)) {
$oMessage->ReadReceipt = \trim($oHeaders->ValueByName(MimeHeader::X_CONFIRM_READING_TO));
$sReadReceipt = \trim($oHeaders->ValueByName(MimeHeader::DISPOSITION_NOTIFICATION_TO));
if (empty($sReadReceipt)) {
$sReadReceipt = \trim($oHeaders->ValueByName(MimeHeader::X_CONFIRM_READING_TO));
}
if ($sReadReceipt) {
try
{
if (!\MailSo\Mime\Email::Parse($sReadReceipt)) {
$sReadReceipt = '';
}
}
catch (\Throwable $oException)
{
$sReadReceipt = '';
}
}
$oMessage->ReadReceipt = $sReadReceipt;
if ($spam = $oHeaders->ValueByName(MimeHeader::X_SPAMD_RESULT)) {
if (\preg_match('/\\[([\\d\\.-]+)\\s*\\/\\s*([\\d\\.]+)\\];/', $spam, $match)) {
@ -461,21 +474,6 @@ class Message implements \JsonSerializable
}
}
$aFlags = $this->getFlags();
$sReadReceipt = $this->ReadReceipt;
if (\strlen($sReadReceipt) && !\in_array('$forwarded', $aFlags)) {
try
{
if (!\MailSo\Mime\Email::Parse($sReadReceipt)) {
$sReadReceipt = '';
}
}
catch (\Throwable $oException)
{
$sReadReceipt = '';
}
}
$result = array(
'@Object' => 'Object/Message',
'folder' => $this->sFolder,
@ -499,7 +497,7 @@ class Message implements \JsonSerializable
'sender' => $this->oSender,
'deliveredTo' => $this->oDeliveredTo,
'readReceipt' => $sReadReceipt,
'readReceipt' => $this->ReadReceipt,
'autocrypt' => $aAutocrypt ?: null,
'attachments' => $this->Attachments,
@ -508,7 +506,7 @@ class Message implements \JsonSerializable
'dkim' => $this->DKIM,
'dmarc' => $this->DMARC,
'flags' => $aFlags,
'flags' => $this->getFlags(),
'inReplyTo' => $this->InReplyTo,

View file

@ -368,14 +368,15 @@ trait Messages
$sFolderFullName = $this->GetActionParam('messageFolder', '');
$iUid = (int) $this->GetActionParam('messageUid', 0);
$this->Cacher($oAccount)->Set(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $sFolderFullName, $iUid), '1');
if (\strlen($sFolderFullName) && 0 < $iUid) {
try
{
$this->MailClient()->MessageSetFlag($sFolderFullName, new SequenceSet($iUid), MessageFlag::MDNSENT, true, true);
}
catch (\Throwable $oException) {}
catch (\Throwable $oException)
{
$this->Cacher($oAccount)->Set(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $sFolderFullName, $iUid), '1');
}
}
}
}

View file

@ -96,7 +96,7 @@ trait Response
if (!$this->Config()->Get('labs', 'date_from_headers', true) && $aResult['internalTimestamp']) {
$aResult['dateTimestamp'] = $aResult['internalTimestamp'];
}
if (!$sParent && \strlen($aResult['readReceipt']) && !\in_array('$forwarded', $aResult['flags'])) {
if (!$sParent && \strlen($aResult['readReceipt']) && !\in_array('$mdnsent', $aResult['flags']) && !\in_array('\\answered', $aResult['flags'])) {
$oAccount = $this->getAccountFromToken();
if ('1' === $this->Cacher($oAccount)->Get(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $aResult['folder'], $aResult['uid']), '0')) {
$aResult['readReceipt'] = '';