MR changes
This commit is contained in:
parent
ce6ee1a105
commit
517bcb632e
|
@ -20,6 +20,7 @@ E211 = "250 SL E211 Bounce Forward phase handled"
|
||||||
E212 = "250 SL E212 Bounce Reply phase handled"
|
E212 = "250 SL E212 Bounce Reply phase handled"
|
||||||
E213 = "250 SL E213 Unknown email ignored"
|
E213 = "250 SL E213 Unknown email ignored"
|
||||||
E214 = "250 SL E214 Unauthorized for using reverse alias"
|
E214 = "250 SL E214 Unauthorized for using reverse alias"
|
||||||
|
E215 = "250 SL E215 Handled dmarc policy"
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
|
@ -554,8 +554,15 @@ def apply_dmarc_policy(
|
||||||
DmarcCheckResult.soft_fail,
|
DmarcCheckResult.soft_fail,
|
||||||
):
|
):
|
||||||
quarantine_dmarc_failed_email(alias, contact, envelope, msg)
|
quarantine_dmarc_failed_email(alias, contact, envelope, msg)
|
||||||
add_quarantine_notification_for_alias(alias)
|
Notification.create(
|
||||||
return status.E519
|
user_id=alias.user_id,
|
||||||
|
title=f"{alias.email} has a new mail in quarantine",
|
||||||
|
message=Notification.render(
|
||||||
|
"notification/message-quarantine.html", alias=alias
|
||||||
|
),
|
||||||
|
commit=True,
|
||||||
|
)
|
||||||
|
return status.E215
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -592,30 +599,6 @@ def quarantine_dmarc_failed_email(alias, contact, envelope, msg):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def add_quarantine_notification_for_alias(alias: Alias):
|
|
||||||
notification_title = f"{alias.email} has a new mail in quarantine"
|
|
||||||
notifications = (
|
|
||||||
Notification.filter_by(user_id=alias.user_id)
|
|
||||||
.order_by(Notification.read, Notification.created_at.desc())
|
|
||||||
.limit(10)
|
|
||||||
.all()
|
|
||||||
) # load a record more to know whether there's more
|
|
||||||
already_notified = False
|
|
||||||
for notification in notifications:
|
|
||||||
if notification.title == notification_title:
|
|
||||||
already_notified = True
|
|
||||||
break
|
|
||||||
if not already_notified:
|
|
||||||
Notification.create(
|
|
||||||
user_id=alias.user_id,
|
|
||||||
title=notification_title,
|
|
||||||
message=Notification.render(
|
|
||||||
"notification/message-quarantine.html", alias=alias
|
|
||||||
),
|
|
||||||
commit=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def handle_forward(envelope, msg: Message, rcpt_to: str) -> List[Tuple[bool, str]]:
|
def handle_forward(envelope, msg: Message, rcpt_to: str) -> List[Tuple[bool, str]]:
|
||||||
"""return an array of SMTP status (is_success, smtp_status)
|
"""return an array of SMTP status (is_success, smtp_status)
|
||||||
is_success indicates whether an email has been delivered and
|
is_success indicates whether an email has been delivered and
|
||||||
|
|
Loading…
Reference in a new issue