mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 13:39:22 +03:00
Move more JSON code into MailSo\Mail\Message
This commit is contained in:
parent
a019f4d80e
commit
49f76ffe76
7 changed files with 75 additions and 70 deletions
|
|
@ -85,7 +85,8 @@ export class MessageModel extends AbstractModel {
|
|||
spamResult: '',
|
||||
isSpam: false,
|
||||
hasVirus: null, // or boolean when scanned
|
||||
dateTimeStampInUTC: 0,
|
||||
dateTimestamp: 0,
|
||||
internalTimestamp: 0,
|
||||
priority: MessagePriority.Normal,
|
||||
|
||||
senderEmailsString: '',
|
||||
|
|
@ -341,7 +342,7 @@ export class MessageModel extends AbstractModel {
|
|||
|
||||
viewPopupMessage(print) {
|
||||
const
|
||||
timeStampInUTC = this.dateTimeStampInUTC() || 0,
|
||||
timeStampInUTC = this.dateTimestamp() || 0,
|
||||
ccLine = this.cc.toString(),
|
||||
bccLine = this.bcc.toString(),
|
||||
m = 0 < timeStampInUTC ? new Date(timeStampInUTC * 1000) : null,
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ export class MailMessageList extends AbstractViewRight {
|
|||
rtf = Intl.RelativeTimeFormat
|
||||
? new Intl.RelativeTimeFormat(doc.documentElement.lang, { numeric: "auto" }) : 0;
|
||||
MessagelistUserStore.forEach(msg => {
|
||||
let dt = (new Date(msg.dateTimeStampInUTC() * 1000)),
|
||||
let dt = (new Date(msg.dateTimestamp() * 1000)),
|
||||
date,
|
||||
ymd = Ymd(dt);
|
||||
if (!current || ymd != current.id) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class Message implements \JsonSerializable
|
|||
$iSize = 0,
|
||||
$SpamScore = 0,
|
||||
$iInternalTimeStampInUTC = 0,
|
||||
$HeaderTimeStampInUTC = 0,
|
||||
$iHeaderTimeStampInUTC = 0,
|
||||
$iPriority = \MailSo\Mime\Enumerations\MessagePriority::NORMAL;
|
||||
|
||||
private bool
|
||||
|
|
@ -107,26 +107,11 @@ class Message implements \JsonSerializable
|
|||
return $this->Uid;
|
||||
}
|
||||
|
||||
public function HeaderTimeStampInUTC() : int
|
||||
{
|
||||
return $this->HeaderTimeStampInUTC;
|
||||
}
|
||||
|
||||
public function Attachments() : ?AttachmentCollection
|
||||
{
|
||||
return $this->Attachments;
|
||||
}
|
||||
|
||||
public function Plain() : string
|
||||
{
|
||||
return $this->sPlain;
|
||||
}
|
||||
|
||||
public function Html() : string
|
||||
{
|
||||
return $this->sHtml;
|
||||
}
|
||||
|
||||
private function setSpamScore($value) : void
|
||||
{
|
||||
$this->SpamScore = \intval(\max(0, \min(100, $value)));
|
||||
|
|
@ -200,7 +185,7 @@ class Message implements \JsonSerializable
|
|||
$oMessage->References = Utils::StripSpaces(
|
||||
$oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::REFERENCES));
|
||||
|
||||
$oMessage->HeaderTimeStampInUTC = \MailSo\Base\DateTimeHelper::ParseRFC2822DateString(
|
||||
$oMessage->iHeaderTimeStampInUTC = \MailSo\Base\DateTimeHelper::ParseRFC2822DateString(
|
||||
$oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::DATE)
|
||||
);
|
||||
|
||||
|
|
@ -507,6 +492,21 @@ 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,
|
||||
|
|
@ -520,7 +520,8 @@ class Message implements \JsonSerializable
|
|||
'isSpam' => $this->bIsSpam,
|
||||
'hasVirus' => $this->bHasVirus,
|
||||
// 'virusScanned' => $this->sVirusScanned,
|
||||
'dateTimeStampInUTC' => $this->iInternalTimeStampInUTC,
|
||||
'dateTimestamp' => $this->iHeaderTimeStampInUTC ?: $this->iInternalTimeStampInUTC,
|
||||
'internalTimestamp' => $this->iInternalTimeStampInUTC,
|
||||
|
||||
// \MailSo\Mime\EmailCollection
|
||||
'from' => $this->oFrom,
|
||||
|
|
@ -532,8 +533,7 @@ class Message implements \JsonSerializable
|
|||
'deliveredTo' => $this->oDeliveredTo,
|
||||
|
||||
'priority' => $this->iPriority,
|
||||
'unsubsribeLinks' => $this->UnsubsribeLinks,
|
||||
'readReceipt' => '',
|
||||
'readReceipt' => $sReadReceipt,
|
||||
'autocrypt' => $aAutocrypt ?: null,
|
||||
|
||||
'attachments' => $this->Attachments,
|
||||
|
|
@ -542,7 +542,7 @@ class Message implements \JsonSerializable
|
|||
'dkim' => $this->DKIM,
|
||||
'dmarc' => $this->DMARC,
|
||||
|
||||
'flags' => $this->getFlags(),
|
||||
'flags' => $aFlags,
|
||||
|
||||
'inReplyTo' => $this->InReplyTo,
|
||||
|
||||
|
|
@ -555,6 +555,27 @@ class Message implements \JsonSerializable
|
|||
'size' => $this->iSize
|
||||
);
|
||||
|
||||
if ($this->DraftInfo) {
|
||||
$result['draftInfo'] = $this->DraftInfo;
|
||||
}
|
||||
if ($this->UnsubsribeLinks) {
|
||||
$result['unsubsribeLinks'] = $this->UnsubsribeLinks;
|
||||
}
|
||||
if ($this->References) {
|
||||
$result['references'] = $this->References;
|
||||
}
|
||||
if ($this->sHtml || $this->sPlain) {
|
||||
$result['html'] = $this->sHtml;
|
||||
$result['plain'] = $this->sPlain;
|
||||
}
|
||||
// $this->GetCapa(Capa::OPEN_PGP) || $this->GetCapa(Capa::GNUPG)
|
||||
if ($this->pgpSigned) {
|
||||
$result['pgpSigned'] = $this->pgpSigned;
|
||||
}
|
||||
if ($this->pgpEncrypted) {
|
||||
$result['pgpEncrypted'] = $this->pgpEncrypted;
|
||||
}
|
||||
|
||||
if ($this->aThreads) {
|
||||
$result['threads'] = $this->aThreads;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,47 +93,13 @@ trait Response
|
|||
|
||||
if ($mResponse instanceof \MailSo\Mail\Message) {
|
||||
$aResult = $mResponse->jsonSerialize();
|
||||
|
||||
if (!$aResult['dateTimeStampInUTC'] || $this->Config()->Get('labs', 'date_from_headers', true)) {
|
||||
$iDateTimeStampInUTC = $mResponse->HeaderTimeStampInUTC;
|
||||
if ($iDateTimeStampInUTC) {
|
||||
$aResult['dateTimeStampInUTC'] = $iDateTimeStampInUTC;
|
||||
}
|
||||
if (!$this->Config()->Get('labs', 'date_from_headers', true) && $aResult['internalTimestamp']) {
|
||||
$aResult['dateTimestamp'] = $aResult['internalTimestamp'];
|
||||
}
|
||||
|
||||
if (!$sParent) {
|
||||
if (!$sParent && \strlen($aResult['readReceipt']) && !\in_array('$forwarded', $aResult['flags'])) {
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
$aResult['draftInfo'] = $mResponse->DraftInfo;
|
||||
$aResult['unsubsribeLinks'] = $mResponse->UnsubsribeLinks;
|
||||
$aResult['references'] = $mResponse->References;
|
||||
|
||||
$aResult['html'] = $mResponse->Html();
|
||||
$aResult['plain'] = $mResponse->Plain();
|
||||
|
||||
// $this->GetCapa(Capa::OPEN_PGP) || $this->GetCapa(Capa::GNUPG)
|
||||
$aResult['pgpSigned'] = $mResponse->pgpSigned;
|
||||
$aResult['pgpEncrypted'] = $mResponse->pgpEncrypted;
|
||||
|
||||
$aResult['readReceipt'] = $mResponse->ReadReceipt;
|
||||
if (\strlen($aResult['readReceipt']) && !\in_array('$forwarded', $aResult['flags'])) {
|
||||
// \in_array('$mdnsent', $aResult['flags'])
|
||||
if (\strlen($aResult['readReceipt'])) {
|
||||
try
|
||||
{
|
||||
$oReadReceipt = \MailSo\Mime\Email::Parse($aResult['readReceipt']);
|
||||
if (!$oReadReceipt) {
|
||||
$aResult['readReceipt'] = '';
|
||||
}
|
||||
}
|
||||
catch (\Throwable $oException) { unset($oException); }
|
||||
}
|
||||
|
||||
if (\strlen($aResult['readReceipt']) && '1' === $this->Cacher($oAccount)->Get(
|
||||
\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $aResult['folder'], $aResult['uid']), '0'))
|
||||
{
|
||||
$aResult['readReceipt'] = '';
|
||||
}
|
||||
if ('1' === $this->Cacher($oAccount)->Get(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $aResult['folder'], $aResult['uid']), '0')) {
|
||||
$aResult['readReceipt'] = '';
|
||||
}
|
||||
}
|
||||
return $aResult;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Config;
|
||||
|
||||
abstract class AbstractConfig implements \JsonSerializable
|
||||
abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
|
||||
{
|
||||
private string $sFile;
|
||||
|
||||
|
|
@ -33,6 +33,23 @@ abstract class AbstractConfig implements \JsonSerializable
|
|||
\MailSo\Base\Utils::FunctionsCallable(array('apcu_fetch', 'apcu_store'));
|
||||
}
|
||||
|
||||
public function offsetExists($offset) : bool
|
||||
{
|
||||
}
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
$offset = \explode('/', $offset, 2);
|
||||
$this->Get($offset[0], $offset[1]);
|
||||
}
|
||||
public function offsetSet($offset, $value) : void
|
||||
{
|
||||
$offset = \explode('/', $offset, 2);
|
||||
$this->Set($offset[0], $offset[1], $value);
|
||||
}
|
||||
public function offsetUnset($offset) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract function defaultValues() : array;
|
||||
|
||||
public function IsInited() : bool
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@
|
|||
<i data-bind="css: attachmentIconClass"></i>
|
||||
</div>
|
||||
<div class="sizeParent actionHandle" data-bind="text: friendlySize()"></div>
|
||||
<time class="actionHandle" data-bind="attr:{'data-moment-format':$root.timeFormat()}, moment: dateTimeStampInUTC"></time>
|
||||
<time class="actionHandle" data-bind="attr:{'data-moment-format':$root.timeFormat()}, moment: dateTimestamp"></time>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
|
|
@ -161,7 +161,7 @@
|
|||
<i data-bind="css: attachmentIconClass"></i>
|
||||
</div>
|
||||
<div class="sizeParent actionHandle" data-bind="text: friendlySize()"></div>
|
||||
<time class="actionHandle" data-moment-format="AUTO" data-bind="moment: dateTimeStampInUTC"></time>
|
||||
<time class="actionHandle" data-moment-format="AUTO" data-bind="moment: dateTimestamp"></time>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -155,12 +155,12 @@
|
|||
<td data-i18n="GLOBAL/REPLY_TO"></td>
|
||||
<td data-bind="text: replyTo"></td>
|
||||
</tr>
|
||||
<tr data-bind="visible: dateTimeStampInUTC">
|
||||
<tr data-bind="visible: dateTimestamp">
|
||||
<td data-i18n="MESSAGE/LABEL_DATE"></td>
|
||||
<td>
|
||||
<time data-moment-format="FULL" data-bind="moment: dateTimeStampInUTC"></time>
|
||||
<time data-moment-format="FULL" data-bind="moment: dateTimestamp"></time>
|
||||
|
||||
(<time data-moment-format="FROMNOW" data-bind="moment: dateTimeStampInUTC"></time>)
|
||||
(<time data-moment-format="FROMNOW" data-bind="moment: dateTimestamp"></time>)
|
||||
</td>
|
||||
</tr>
|
||||
<tr data-bind="visible: spamResult">
|
||||
|
|
@ -177,7 +177,7 @@
|
|||
<div id="messageItem">
|
||||
<div class="messageItemHeader" data-bind="if: message, i18nUpdate: message">
|
||||
<div data-bind="hidden: showFullInfo">
|
||||
<time class="date" data-moment-format="FULL" data-bind="visible: 0 < message().dateTimeStampInUTC(), moment: message().dateTimeStampInUTC()"></time>
|
||||
<time class="date" data-moment-format="FULL" data-bind="visible: 0 < message().dateTimestamp(), moment: message().dateTimestamp()"></time>
|
||||
<div class="informationShortWrp">
|
||||
<div class="informationShort" data-bind="visible: message().to.length">
|
||||
<span data-i18n="GLOBAL/TO"></span>:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue