Reply only once per user even if they send it from any mailbox

This commit is contained in:
Adrià Casajús 2022-02-17 14:33:04 +01:00
parent b0ac2f871a
commit b069f81920
No known key found for this signature in database
GPG Key ID: F0033226A5AFC9B9
1 changed files with 11 additions and 10 deletions

View File

@ -2080,17 +2080,18 @@ def should_ignore(mail_from: str, rcpt_tos: List[str]) -> bool:
def send_no_reply_response(mail_from: str, msg: Message):
user = User.get_by(email=mail_from)
if user:
send_email_at_most_times(
user,
ALERT_TO_NOREPLY,
user.email,
"Auto: {}".format(msg[headers.SUBJECT] or "No subject"),
render("transactional/noreply.text.jinja2"),
)
else:
mailbox = Mailbox.get_by(email=mail_from)
user = User.get(mailbox.user_id)
if not user:
LOG.d("Unknown sender. Skipping reply from {}".format(NOREPLY))
return
send_email_at_most_times(
user,
ALERT_TO_NOREPLY,
user.email,
"Auto: {}".format(msg[headers.SUBJECT] or "No subject"),
render("transactional/noreply.text.jinja2"),
)
def handle(envelope: Envelope, msg: Message) -> str: