mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 15:37:03 +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: '',
|
spamResult: '',
|
||||||
isSpam: false,
|
isSpam: false,
|
||||||
hasVirus: null, // or boolean when scanned
|
hasVirus: null, // or boolean when scanned
|
||||||
dateTimeStampInUTC: 0,
|
dateTimestamp: 0,
|
||||||
|
internalTimestamp: 0,
|
||||||
priority: MessagePriority.Normal,
|
priority: MessagePriority.Normal,
|
||||||
|
|
||||||
senderEmailsString: '',
|
senderEmailsString: '',
|
||||||
|
|
@ -341,7 +342,7 @@ export class MessageModel extends AbstractModel {
|
||||||
|
|
||||||
viewPopupMessage(print) {
|
viewPopupMessage(print) {
|
||||||
const
|
const
|
||||||
timeStampInUTC = this.dateTimeStampInUTC() || 0,
|
timeStampInUTC = this.dateTimestamp() || 0,
|
||||||
ccLine = this.cc.toString(),
|
ccLine = this.cc.toString(),
|
||||||
bccLine = this.bcc.toString(),
|
bccLine = this.bcc.toString(),
|
||||||
m = 0 < timeStampInUTC ? new Date(timeStampInUTC * 1000) : null,
|
m = 0 < timeStampInUTC ? new Date(timeStampInUTC * 1000) : null,
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ export class MailMessageList extends AbstractViewRight {
|
||||||
rtf = Intl.RelativeTimeFormat
|
rtf = Intl.RelativeTimeFormat
|
||||||
? new Intl.RelativeTimeFormat(doc.documentElement.lang, { numeric: "auto" }) : 0;
|
? new Intl.RelativeTimeFormat(doc.documentElement.lang, { numeric: "auto" }) : 0;
|
||||||
MessagelistUserStore.forEach(msg => {
|
MessagelistUserStore.forEach(msg => {
|
||||||
let dt = (new Date(msg.dateTimeStampInUTC() * 1000)),
|
let dt = (new Date(msg.dateTimestamp() * 1000)),
|
||||||
date,
|
date,
|
||||||
ymd = Ymd(dt);
|
ymd = Ymd(dt);
|
||||||
if (!current || ymd != current.id) {
|
if (!current || ymd != current.id) {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class Message implements \JsonSerializable
|
||||||
$iSize = 0,
|
$iSize = 0,
|
||||||
$SpamScore = 0,
|
$SpamScore = 0,
|
||||||
$iInternalTimeStampInUTC = 0,
|
$iInternalTimeStampInUTC = 0,
|
||||||
$HeaderTimeStampInUTC = 0,
|
$iHeaderTimeStampInUTC = 0,
|
||||||
$iPriority = \MailSo\Mime\Enumerations\MessagePriority::NORMAL;
|
$iPriority = \MailSo\Mime\Enumerations\MessagePriority::NORMAL;
|
||||||
|
|
||||||
private bool
|
private bool
|
||||||
|
|
@ -107,26 +107,11 @@ class Message implements \JsonSerializable
|
||||||
return $this->Uid;
|
return $this->Uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HeaderTimeStampInUTC() : int
|
|
||||||
{
|
|
||||||
return $this->HeaderTimeStampInUTC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function Attachments() : ?AttachmentCollection
|
public function Attachments() : ?AttachmentCollection
|
||||||
{
|
{
|
||||||
return $this->Attachments;
|
return $this->Attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Plain() : string
|
|
||||||
{
|
|
||||||
return $this->sPlain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function Html() : string
|
|
||||||
{
|
|
||||||
return $this->sHtml;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function setSpamScore($value) : void
|
private function setSpamScore($value) : void
|
||||||
{
|
{
|
||||||
$this->SpamScore = \intval(\max(0, \min(100, $value)));
|
$this->SpamScore = \intval(\max(0, \min(100, $value)));
|
||||||
|
|
@ -200,7 +185,7 @@ class Message implements \JsonSerializable
|
||||||
$oMessage->References = Utils::StripSpaces(
|
$oMessage->References = Utils::StripSpaces(
|
||||||
$oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::REFERENCES));
|
$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)
|
$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(
|
$result = array(
|
||||||
'@Object' => 'Object/Message',
|
'@Object' => 'Object/Message',
|
||||||
'folder' => $this->sFolder,
|
'folder' => $this->sFolder,
|
||||||
|
|
@ -520,7 +520,8 @@ class Message implements \JsonSerializable
|
||||||
'isSpam' => $this->bIsSpam,
|
'isSpam' => $this->bIsSpam,
|
||||||
'hasVirus' => $this->bHasVirus,
|
'hasVirus' => $this->bHasVirus,
|
||||||
// 'virusScanned' => $this->sVirusScanned,
|
// 'virusScanned' => $this->sVirusScanned,
|
||||||
'dateTimeStampInUTC' => $this->iInternalTimeStampInUTC,
|
'dateTimestamp' => $this->iHeaderTimeStampInUTC ?: $this->iInternalTimeStampInUTC,
|
||||||
|
'internalTimestamp' => $this->iInternalTimeStampInUTC,
|
||||||
|
|
||||||
// \MailSo\Mime\EmailCollection
|
// \MailSo\Mime\EmailCollection
|
||||||
'from' => $this->oFrom,
|
'from' => $this->oFrom,
|
||||||
|
|
@ -532,8 +533,7 @@ class Message implements \JsonSerializable
|
||||||
'deliveredTo' => $this->oDeliveredTo,
|
'deliveredTo' => $this->oDeliveredTo,
|
||||||
|
|
||||||
'priority' => $this->iPriority,
|
'priority' => $this->iPriority,
|
||||||
'unsubsribeLinks' => $this->UnsubsribeLinks,
|
'readReceipt' => $sReadReceipt,
|
||||||
'readReceipt' => '',
|
|
||||||
'autocrypt' => $aAutocrypt ?: null,
|
'autocrypt' => $aAutocrypt ?: null,
|
||||||
|
|
||||||
'attachments' => $this->Attachments,
|
'attachments' => $this->Attachments,
|
||||||
|
|
@ -542,7 +542,7 @@ class Message implements \JsonSerializable
|
||||||
'dkim' => $this->DKIM,
|
'dkim' => $this->DKIM,
|
||||||
'dmarc' => $this->DMARC,
|
'dmarc' => $this->DMARC,
|
||||||
|
|
||||||
'flags' => $this->getFlags(),
|
'flags' => $aFlags,
|
||||||
|
|
||||||
'inReplyTo' => $this->InReplyTo,
|
'inReplyTo' => $this->InReplyTo,
|
||||||
|
|
||||||
|
|
@ -555,6 +555,27 @@ class Message implements \JsonSerializable
|
||||||
'size' => $this->iSize
|
'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) {
|
if ($this->aThreads) {
|
||||||
$result['threads'] = $this->aThreads;
|
$result['threads'] = $this->aThreads;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,47 +93,13 @@ trait Response
|
||||||
|
|
||||||
if ($mResponse instanceof \MailSo\Mail\Message) {
|
if ($mResponse instanceof \MailSo\Mail\Message) {
|
||||||
$aResult = $mResponse->jsonSerialize();
|
$aResult = $mResponse->jsonSerialize();
|
||||||
|
if (!$this->Config()->Get('labs', 'date_from_headers', true) && $aResult['internalTimestamp']) {
|
||||||
if (!$aResult['dateTimeStampInUTC'] || $this->Config()->Get('labs', 'date_from_headers', true)) {
|
$aResult['dateTimestamp'] = $aResult['internalTimestamp'];
|
||||||
$iDateTimeStampInUTC = $mResponse->HeaderTimeStampInUTC;
|
|
||||||
if ($iDateTimeStampInUTC) {
|
|
||||||
$aResult['dateTimeStampInUTC'] = $iDateTimeStampInUTC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!$sParent && \strlen($aResult['readReceipt']) && !\in_array('$forwarded', $aResult['flags'])) {
|
||||||
if (!$sParent) {
|
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
if ('1' === $this->Cacher($oAccount)->Get(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $aResult['folder'], $aResult['uid']), '0')) {
|
||||||
$aResult['draftInfo'] = $mResponse->DraftInfo;
|
$aResult['readReceipt'] = '';
|
||||||
$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'] = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $aResult;
|
return $aResult;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace RainLoop\Config;
|
namespace RainLoop\Config;
|
||||||
|
|
||||||
abstract class AbstractConfig implements \JsonSerializable
|
abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
|
||||||
{
|
{
|
||||||
private string $sFile;
|
private string $sFile;
|
||||||
|
|
||||||
|
|
@ -33,6 +33,23 @@ abstract class AbstractConfig implements \JsonSerializable
|
||||||
\MailSo\Base\Utils::FunctionsCallable(array('apcu_fetch', 'apcu_store'));
|
\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;
|
protected abstract function defaultValues() : array;
|
||||||
|
|
||||||
public function IsInited() : bool
|
public function IsInited() : bool
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@
|
||||||
<i data-bind="css: attachmentIconClass"></i>
|
<i data-bind="css: attachmentIconClass"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="sizeParent actionHandle" data-bind="text: friendlySize()"></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>
|
||||||
</div>
|
</div>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
|
|
@ -161,7 +161,7 @@
|
||||||
<i data-bind="css: attachmentIconClass"></i>
|
<i data-bind="css: attachmentIconClass"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="sizeParent actionHandle" data-bind="text: friendlySize()"></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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -155,12 +155,12 @@
|
||||||
<td data-i18n="GLOBAL/REPLY_TO"></td>
|
<td data-i18n="GLOBAL/REPLY_TO"></td>
|
||||||
<td data-bind="text: replyTo"></td>
|
<td data-bind="text: replyTo"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr data-bind="visible: dateTimeStampInUTC">
|
<tr data-bind="visible: dateTimestamp">
|
||||||
<td data-i18n="MESSAGE/LABEL_DATE"></td>
|
<td data-i18n="MESSAGE/LABEL_DATE"></td>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr data-bind="visible: spamResult">
|
<tr data-bind="visible: spamResult">
|
||||||
|
|
@ -177,7 +177,7 @@
|
||||||
<div id="messageItem">
|
<div id="messageItem">
|
||||||
<div class="messageItemHeader" data-bind="if: message, i18nUpdate: message">
|
<div class="messageItemHeader" data-bind="if: message, i18nUpdate: message">
|
||||||
<div data-bind="hidden: showFullInfo">
|
<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="informationShortWrp">
|
||||||
<div class="informationShort" data-bind="visible: message().to.length">
|
<div class="informationShort" data-bind="visible: message().to.length">
|
||||||
<span data-i18n="GLOBAL/TO"></span>:
|
<span data-i18n="GLOBAL/TO"></span>:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue