mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Set SpamScore to 100% when bIsSpam #320
This commit is contained in:
parent
59857e66e7
commit
afeeceaf77
1 changed files with 9 additions and 4 deletions
|
|
@ -140,6 +140,11 @@ class Message implements \JsonSerializable
|
||||||
return $this->iSpamScore;
|
return $this->iSpamScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setSpamScore($value) : void
|
||||||
|
{
|
||||||
|
$this->iSpamScore = \intval(\max(0, \min(100, $value)));
|
||||||
|
}
|
||||||
|
|
||||||
public function SpamResult() : string
|
public function SpamResult() : string
|
||||||
{
|
{
|
||||||
return $this->sSpamResult;
|
return $this->sSpamResult;
|
||||||
|
|
@ -402,7 +407,7 @@ class Message implements \JsonSerializable
|
||||||
if ($spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAMD_RESULT)) {
|
if ($spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAMD_RESULT)) {
|
||||||
if (\preg_match('/\\[([\\d\\.-]+)\\s*\\/\\s*([\\d\\.]+)\\];/', $spam, $match)) {
|
if (\preg_match('/\\[([\\d\\.-]+)\\s*\\/\\s*([\\d\\.]+)\\];/', $spam, $match)) {
|
||||||
if ($threshold = \floatval($match[2])) {
|
if ($threshold = \floatval($match[2])) {
|
||||||
$oMessage->iSpamScore = \intval(\max(0, \min(100, 100 * \floatval($match[1]) / $threshold)));
|
$oMessage->setSpamScore(100 * \floatval($match[1]) / $threshold);
|
||||||
$oMessage->sSpamResult = "{$match[1]} / {$match[2]}";
|
$oMessage->sSpamResult = "{$match[1]} / {$match[2]}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -411,14 +416,14 @@ class Message implements \JsonSerializable
|
||||||
$oMessage->sSpamResult = $spam;
|
$oMessage->sSpamResult = $spam;
|
||||||
$oMessage->bIsSpam = !!\preg_match('/yes|spam/', $spam);
|
$oMessage->bIsSpam = !!\preg_match('/yes|spam/', $spam);
|
||||||
if (\preg_match('/spamicity=([\\d\\.]+)/', $spam, $spamicity)) {
|
if (\preg_match('/spamicity=([\\d\\.]+)/', $spam, $spamicity)) {
|
||||||
$oMessage->iSpamScore = \intval(\max(0, \min(100, \floatval($spamicity[1]))));
|
$oMessage->setSpamScore(\floatval($spamicity[1]));
|
||||||
}
|
}
|
||||||
} else if ($spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAM_STATUS)) {
|
} else if ($spam = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_SPAM_STATUS)) {
|
||||||
$oMessage->sSpamResult = $spam;
|
$oMessage->sSpamResult = $spam;
|
||||||
if (\preg_match('/(?:hits|score)=([\\d\\.-]+)/', $spam, $value)
|
if (\preg_match('/(?:hits|score)=([\\d\\.-]+)/', $spam, $value)
|
||||||
&& \preg_match('/required=([\\d\\.-]+)/', $spam, $required)) {
|
&& \preg_match('/required=([\\d\\.-]+)/', $spam, $required)) {
|
||||||
if ($threshold = \floatval($required[1])) {
|
if ($threshold = \floatval($required[1])) {
|
||||||
$oMessage->iSpamScore = \intval(\max(0, \min(100, 100 * \floatval($value[1]) / $threshold)));
|
$oMessage->setSpamScore(100 * \floatval($value[1]) / $threshold);
|
||||||
$oMessage->sSpamResult = "{$value[1]} / {$required[1]}";
|
$oMessage->sSpamResult = "{$value[1]} / {$required[1]}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -624,7 +629,7 @@ class Message implements \JsonSerializable
|
||||||
'Subject' => \trim(Utils::Utf8Clear($this->sSubject)),
|
'Subject' => \trim(Utils::Utf8Clear($this->sSubject)),
|
||||||
'MessageId' => $this->sMessageId,
|
'MessageId' => $this->sMessageId,
|
||||||
'Size' => $this->iSize,
|
'Size' => $this->iSize,
|
||||||
'SpamScore' => $this->iSpamScore,
|
'SpamScore' => $this->bIsSpam ? 100 : $this->iSpamScore,
|
||||||
'SpamResult' => $this->sSpamResult,
|
'SpamResult' => $this->sSpamResult,
|
||||||
'IsSpam' => $this->bIsSpam,
|
'IsSpam' => $this->bIsSpam,
|
||||||
'HasVirus' => $this->bHasVirus,
|
'HasVirus' => $this->bHasVirus,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue