Added SpamResult

This commit is contained in:
djmaze 2021-04-09 09:01:48 +02:00
parent 7fc279293c
commit 3d10bbface
3 changed files with 15 additions and 3 deletions

View file

@ -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());

View file

@ -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());

View file

@ -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(),