Add OLD_UNSUBSCRIBER and support it

This commit is contained in:
Son 2021-11-22 18:17:07 +01:00
parent 64d2e7804e
commit eeb24f594a
2 changed files with 5 additions and 1 deletions

View File

@ -157,6 +157,9 @@ DISABLE_ALIAS_SUFFIX = "DISABLE_ALIAS_SUFFIX" in os.environ
# the email address that receives all unsubscription request
UNSUBSCRIBER = os.environ.get("UNSUBSCRIBER")
# due to a typo, both UNSUBSCRIBER and OLD_UNSUBSCRIBER are supported
OLD_UNSUBSCRIBER = os.environ.get("OLD_UNSUBSCRIBER")
DKIM_SELECTOR = b"dkim"
DKIM_PRIVATE_KEY = None

View File

@ -86,6 +86,7 @@ from app.config import (
TEMP_DIR,
ALERT_HOTMAIL_COMPLAINT_TRANSACTIONAL,
ALERT_HOTMAIL_COMPLAINT_REPLY_PHASE,
OLD_UNSUBSCRIBER,
)
from app.db import Session
from app.email import status, headers
@ -2015,7 +2016,7 @@ def handle(envelope: Envelope) -> str:
return status.E203
# unsubscribe request
if UNSUBSCRIBER and rcpt_tos == [UNSUBSCRIBER]:
if UNSUBSCRIBER and (rcpt_tos == [UNSUBSCRIBER] or rcpt_tos == [OLD_UNSUBSCRIBER]):
LOG.d("Handle unsubscribe request from %s", mail_from)
return handle_unsubscribe(envelope, msg)