From 3d10bbface3a0a663a2b84a58189ed6d1453fbd9 Mon Sep 17 00:00:00 2001 From: djmaze Date: Fri, 9 Apr 2021 09:01:48 +0200 Subject: [PATCH] Added SpamResult --- dev/Model/Message.js | 3 +++ dev/View/User/MailBox/MessageView.js | 2 +- .../v/0.0.0/app/libraries/MailSo/Mail/Message.php | 13 +++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dev/Model/Message.js b/dev/Model/Message.js index 8b134600b..a5b4b0dd1 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -46,6 +46,7 @@ export class MessageModel extends AbstractModel { subject: '', size: 0, spamScore: 0, + spamResult: '', isSpam: false, dateTimeStampInUTC: 0, priority: MessagePriority.Normal, @@ -119,6 +120,7 @@ export class MessageModel extends AbstractModel { this.subject(''); this.size(0); this.spamScore(0); + this.spamResult(''); this.isSpam(false); this.dateTimeStampInUTC(0); this.priority(MessagePriority.Normal); @@ -419,6 +421,7 @@ export class MessageModel extends AbstractModel { this.size(message.size()); this.spamScore(message.spamScore()); + this.spamResult(message.spamResult()); this.isSpam(message.isSpam()); this.dateTimeStampInUTC(message.dateTimeStampInUTC()); this.priority(message.priority()); diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 0391d7017..c3301dced 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -227,7 +227,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { this.viewTimeStamp(message.dateTimeStampInUTC()); this.viewSize(message.friendlySize()); this.viewSpamScore(message.spamScore()); - this.viewSpamStatus(i18n(message.isSpam() ? 'GLOBAL/SPAM' : 'GLOBAL/NOT_SPAM')); + this.viewSpamStatus(i18n(message.isSpam() ? 'GLOBAL/SPAM' : 'GLOBAL/NOT_SPAM') + ': ' + message.spamResult()); this.viewLineAsCss(message.lineAsCss()); this.viewViewLink(message.viewLink()); this.viewUnsubscribeLink(message.getFirstUnsubsribeLink()); diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php index 521af9008..e22753226 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Message.php @@ -25,6 +25,7 @@ class Message implements \JsonSerializable $sContentType = '', $iSize = 0, $iSpamScore = 0, + $sSpamResult = '', $bIsSpam = false, $iInternalTimeStampInUTC = 0, $iHeaderTimeStampInUTC = 0, @@ -248,6 +249,11 @@ class Message implements \JsonSerializable return $this->iSpamScore; } + public function SpamResult() : string + { + return $this->sSpamResult; + } + public function IsSpam() : bool { return $this->bIsSpam; @@ -530,14 +536,16 @@ class Message implements \JsonSerializable if (\preg_match('/\\[([\\d\\.-]+)\\s*\\/\\s*([\\d\\.]+)\\];/', $spam, $match)) { if ($threshold = \floatval($match[2])) { $this->iSpamScore = \max(0, \min(100, 100 * \floatval($match[1]) / $threshold)); + $this->sSpamResult = "{$match[1]} / {$match[2]}"; } $this->bIsSpam = false !== \stripos($this->sSubject, '*** SPAM ***'); } else { $spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAM_STATUS); if (\preg_match('/(?:hits|score)=([\\d\\.-]+)/', $spam, $value) - && \preg_match('/required=([\\d\\.-]+)/', $spam, $threshold)) { - if ($threshold = \floatval($threshold[1])) { + && \preg_match('/required=([\\d\\.-]+)/', $spam, $required)) { + if ($threshold = \floatval($required[1])) { $this->iSpamScore = \max(0, \min(100, 100 * \floatval($value[1]) / $threshold)); + $this->sSpamResult = "{$value[1]} / {$required[1]}"; } } $spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAM_FLAG); @@ -723,6 +731,7 @@ class Message implements \JsonSerializable 'MessageId' => $this->MessageId(), 'Size' => $this->Size(), 'SpamScore' => $this->SpamScore(), + 'SpamResult' => $this->SpamResult(), 'IsSpam' => $this->IsSpam(), 'DateTimeStampInUTC' => $this->InternalTimeStampInUTC(),