Handle message hasVirus header in JavaScript

This commit is contained in:
the-djmaze 2024-01-22 13:33:00 +01:00
parent e133cf5ffb
commit f0bb3a8a45
2 changed files with 17 additions and 27 deletions

View file

@ -257,13 +257,28 @@ export class MessageModel extends AbstractModel {
} }
// Unsubscribe links // Unsubscribe links
value = headers.valueByName('List-Unsubscribe'); if (value = headers.valueByName('List-Unsubscribe')) {
if (value) {
this.unsubsribeLinks(value.split(',').map( this.unsubsribeLinks(value.split(',').map(
link => link.replace(/^[ <>]+|[ <>]+$/g, '') link => link.replace(/^[ <>]+|[ <>]+$/g, '')
)); ));
} }
if (headers.valueByName('X-Virus')) {
this.hasVirus(true);
}
if (value = headers.valueByName('X-Virus-Status')) {
if (value.includes('infected')) {
this.hasVirus(true);
} else if (value.includes('clean')) {
this.hasVirus(false);
}
}
/*
if (value = headers.valueByName('X-Virus-Scanned')) {
this.virusScanned(value);
}
*/
return true; return true;
} }
} }

View file

@ -27,7 +27,6 @@ class Message implements \JsonSerializable
$sMessageId = '', $sMessageId = '',
$sContentType = '', $sContentType = '',
$sSpamResult = '', $sSpamResult = '',
$sVirusScanned = '',
$InReplyTo = '', $InReplyTo = '',
$sPlain = '', $sPlain = '',
$sHtml = '', $sHtml = '',
@ -57,14 +56,6 @@ class Message implements \JsonSerializable
private bool private bool
$bIsSpam = false; $bIsSpam = false;
private ?bool
/**
* null = not scanned
* true = scanned and infected
* false = scanned and no infection found
*/
$bHasVirus = null;
private array private array
$SPF = [], $SPF = [],
$DKIM = [], $DKIM = [],
@ -246,20 +237,6 @@ class Message implements \JsonSerializable
|| false !== \stripos($oHeaders->ValueByName(MimeHeader::X_SPAM_FLAG), 'YES'); || false !== \stripos($oHeaders->ValueByName(MimeHeader::X_SPAM_FLAG), 'YES');
} }
if ($virus = $oHeaders->ValueByName(MimeHeader::X_VIRUS)) {
$oMessage->bHasVirus = true;
}
if ($virus = $oHeaders->ValueByName(MimeHeader::X_VIRUS_STATUS)) {
if (false !== \stripos($spam, 'infected')) {
$oMessage->bHasVirus = true;
} else if (false !== \stripos($spam, 'clean')) {
$oMessage->bHasVirus = false;
}
}
if ($virus = $oHeaders->ValueByName(MimeHeader::X_VIRUS_SCANNED)) {
$oMessage->sVirusScanned = $virus;
}
$sDraftInfo = $oHeaders->ValueByName(MimeHeader::X_DRAFT_INFO); $sDraftInfo = $oHeaders->ValueByName(MimeHeader::X_DRAFT_INFO);
if (\strlen($sDraftInfo)) { if (\strlen($sDraftInfo)) {
$sType = ''; $sType = '';
@ -510,8 +487,6 @@ class Message implements \JsonSerializable
'spamScore' => $this->bIsSpam ? 100 : $this->SpamScore, 'spamScore' => $this->bIsSpam ? 100 : $this->SpamScore,
'spamResult' => $this->sSpamResult, 'spamResult' => $this->sSpamResult,
'isSpam' => $this->bIsSpam, 'isSpam' => $this->bIsSpam,
'hasVirus' => $this->bHasVirus,
// 'virusScanned' => $this->sVirusScanned,
'dateTimestamp' => $this->iHeaderTimeStampInUTC ?: $this->iInternalTimeStampInUTC, 'dateTimestamp' => $this->iHeaderTimeStampInUTC ?: $this->iInternalTimeStampInUTC,
'internalTimestamp' => $this->iInternalTimeStampInUTC, 'internalTimestamp' => $this->iInternalTimeStampInUTC,