Do not report complaints for deleted aliases (#1067)
* Do not report complaints for deleted aliases * revert reorder Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
parent
c0fe10def6
commit
a9a44c378a
|
@ -190,11 +190,11 @@ def handle_yahoo_complaint(message: Message) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def find_alias_with_address(address: str) -> Optional[Alias]:
|
def find_alias_with_address(address: str) -> Optional[Alias]:
|
||||||
return (
|
return Alias.get_by(email=address) or DomainDeletedAlias.get_by(email=address)
|
||||||
Alias.get_by(email=address)
|
|
||||||
or DeletedAlias.get_by(email=address)
|
|
||||||
or DomainDeletedAlias.get_by(email=address)
|
def is_deleted_alias(address: str) -> bool:
|
||||||
)
|
return DeletedAlias.get_by(email=address) is not None
|
||||||
|
|
||||||
|
|
||||||
def handle_complaint(message: Message, origin: ProviderComplaintOrigin) -> bool:
|
def handle_complaint(message: Message, origin: ProviderComplaintOrigin) -> bool:
|
||||||
|
@ -220,12 +220,20 @@ def handle_complaint(message: Message, origin: ProviderComplaintOrigin) -> bool:
|
||||||
store_provider_complaint(alias, message)
|
store_provider_complaint(alias, message)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if is_deleted_alias(msg_info.sender_address):
|
||||||
|
LOG.i(f"Complaint is for deleted alias. Do nothing")
|
||||||
|
return True
|
||||||
|
|
||||||
contact = Contact.get_by(reply_email=msg_info.sender_address)
|
contact = Contact.get_by(reply_email=msg_info.sender_address)
|
||||||
if contact:
|
if contact:
|
||||||
alias = contact.alias
|
alias = contact.alias
|
||||||
else:
|
else:
|
||||||
alias = find_alias_with_address(msg_info.rcpt_address)
|
alias = find_alias_with_address(msg_info.rcpt_address)
|
||||||
|
|
||||||
|
if is_deleted_alias(msg_info.rcpt_address):
|
||||||
|
LOG.i(f"Complaint is for deleted alias. Do nothing")
|
||||||
|
return True
|
||||||
|
|
||||||
if not alias:
|
if not alias:
|
||||||
LOG.e(
|
LOG.e(
|
||||||
f"Cannot find alias for address {msg_info.rcpt_address} or contact with reply {msg_info.sender_address}"
|
f"Cannot find alias for address {msg_info.rcpt_address} or contact with reply {msg_info.sender_address}"
|
||||||
|
|
|
@ -2232,6 +2232,7 @@ class DomainDeletedAlias(Base, ModelMixin):
|
||||||
user_id = sa.Column(sa.ForeignKey(User.id, ondelete="cascade"), nullable=False)
|
user_id = sa.Column(sa.ForeignKey(User.id, ondelete="cascade"), nullable=False)
|
||||||
|
|
||||||
domain = orm.relationship(CustomDomain)
|
domain = orm.relationship(CustomDomain)
|
||||||
|
user = orm.relationship(User, foreign_keys=[user_id])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, **kw):
|
def create(cls, **kw):
|
||||||
|
|
Loading…
Reference in New Issue