mirror of
https://github.com/simple-login/app.git
synced 2024-10-31 19:11:01 +01:00
Fix: Use email directly for DomainDeletedAlias (#1273)
* Fix: Use email directly for DomainDeletedAlias * Add handling for reply phase * Use the first mailbox of the domain for deleted domain aliase Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
parent
753a28e886
commit
9c86e1a820
@ -3,7 +3,7 @@ from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass
|
||||
from io import BytesIO
|
||||
from mailbox import Message
|
||||
from typing import Optional
|
||||
from typing import Optional, Union
|
||||
|
||||
from app import s3
|
||||
from app.config import (
|
||||
@ -189,7 +189,7 @@ def handle_yahoo_complaint(message: Message) -> bool:
|
||||
return handle_complaint(message, ProviderComplaintYahoo())
|
||||
|
||||
|
||||
def find_alias_with_address(address: str) -> Optional[Alias]:
|
||||
def find_alias_with_address(address: str) -> Optional[Union[Alias, DomainDeletedAlias]]:
|
||||
return Alias.get_by(email=address) or DomainDeletedAlias.get_by(email=address)
|
||||
|
||||
|
||||
@ -245,16 +245,22 @@ def handle_complaint(message: Message, origin: ProviderComplaintOrigin) -> bool:
|
||||
|
||||
|
||||
def report_complaint_to_user_in_reply_phase(
|
||||
alias: Alias,
|
||||
alias: Union[Alias, DomainDeletedAlias],
|
||||
to_address: str,
|
||||
origin: ProviderComplaintOrigin,
|
||||
msg_info: OriginalMessageInformation,
|
||||
):
|
||||
capitalized_name = origin.name().capitalize()
|
||||
mailbox_email = msg_info.mailbox_address
|
||||
if not mailbox_email:
|
||||
if type(alias) is Alias:
|
||||
mailbox_email = alias.mailbox.email
|
||||
else:
|
||||
mailbox_email = alias.domain.mailboxes[0].email
|
||||
send_email_with_rate_control(
|
||||
alias.user,
|
||||
f"{ALERT_COMPLAINT_REPLY_PHASE}_{origin.name()}",
|
||||
msg_info.mailbox_address or alias.mailbox.email,
|
||||
mailbox_email,
|
||||
f"Abuse report from {capitalized_name}",
|
||||
render(
|
||||
"transactional/provider-complaint-reply-phase.txt.jinja2",
|
||||
@ -293,11 +299,19 @@ def report_complaint_to_user_in_transactional_phase(
|
||||
|
||||
|
||||
def report_complaint_to_user_in_forward_phase(
|
||||
alias: Alias, origin: ProviderComplaintOrigin, msg_info: OriginalMessageInformation
|
||||
alias: Union[Alias, DomainDeletedAlias],
|
||||
origin: ProviderComplaintOrigin,
|
||||
msg_info: OriginalMessageInformation,
|
||||
):
|
||||
capitalized_name = origin.name().capitalize()
|
||||
user = alias.user
|
||||
mailbox_email = msg_info.mailbox_address or alias.mailbox.email
|
||||
|
||||
mailbox_email = msg_info.mailbox_address
|
||||
if not mailbox_email:
|
||||
if type(alias) is Alias:
|
||||
mailbox_email = alias.mailbox.email
|
||||
else:
|
||||
mailbox_email = alias.domain.mailboxes[0].email
|
||||
send_email_with_rate_control(
|
||||
user,
|
||||
f"{ALERT_COMPLAINT_FORWARD_PHASE}_{origin.name()}",
|
||||
|
Loading…
Reference in New Issue
Block a user