only run spam check in email handler if ENABLE_SPAM_ASSASSIN is enabled

This commit is contained in:
Son NK 2021-03-26 10:00:48 +01:00
parent 2270ccf35d
commit 365c11f926
1 changed files with 76 additions and 71 deletions

View File

@ -72,6 +72,7 @@ from app.config import (
BOUNCE_SUFFIX,
TRANSACTIONAL_BOUNCE_PREFIX,
TRANSACTIONAL_BOUNCE_SUFFIX,
ENABLE_SPAM_ASSASSIN,
)
from app.email.spam import get_spam_score
from app.email_utils import (
@ -594,6 +595,7 @@ def forward_email_to_mailbox(
contact_id=contact.id, user_id=user.id, mailbox_id=mailbox.id, commit=True
)
if ENABLE_SPAM_ASSASSIN:
# Spam check
spam_status = ""
is_spam = False
@ -818,6 +820,7 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
)
# Spam check
if ENABLE_SPAM_ASSASSIN:
spam_status = ""
is_spam = False
@ -839,7 +842,9 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
# only set the spam report for spam
email_log.spam_report = spam_report
else:
is_spam, spam_status = get_spam_info(msg, max_score=MAX_REPLY_PHASE_SPAM_SCORE)
is_spam, spam_status = get_spam_info(
msg, max_score=MAX_REPLY_PHASE_SPAM_SCORE
)
if is_spam:
LOG.w(