mirror of
https://github.com/simple-login/app.git
synced 2024-09-20 06:55:59 +08:00
raise error when a non reverse-alias is used during the reply phase
This commit is contained in:
parent
035d238c75
commit
5195c9de8b
|
@ -20,3 +20,9 @@ class CannotCreateContactForReverseAlias(Exception):
|
|||
"""raised when a contact is created that has website_email=reverse_alias of another contact"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class NonReverseAliasInReplyPhase(Exception):
|
||||
"""raised when a non reverse-alias is used during a reply phase"""
|
||||
|
||||
pass
|
||||
|
|
|
@ -127,6 +127,7 @@ from app.email_utils import (
|
|||
get_mailbox_bounce_info,
|
||||
save_email_for_debugging,
|
||||
)
|
||||
from app.errors import NonReverseAliasInReplyPhase
|
||||
from app.log import LOG, set_message_id
|
||||
from app.models import (
|
||||
Alias,
|
||||
|
@ -373,16 +374,21 @@ def replace_header_when_reply(msg: Message, alias: Alias, header: str):
|
|||
|
||||
for _, reply_email in getaddresses(headers):
|
||||
# no transformation when alias is already in the header
|
||||
# can happen when user clicks "Reply All"
|
||||
if reply_email == alias.email:
|
||||
continue
|
||||
|
||||
contact = Contact.get_by(reply_email=reply_email)
|
||||
if not contact:
|
||||
LOG.w(
|
||||
"%s email in reply phase %s must be reply emails", header, reply_email
|
||||
"email %s contained in %s header in reply phase %s must be reply emails. headers:%s",
|
||||
reply_email,
|
||||
header,
|
||||
headers,
|
||||
)
|
||||
raise NonReverseAliasInReplyPhase
|
||||
# still keep this email in header
|
||||
new_addrs.append(reply_email)
|
||||
# new_addrs.append(reply_email)
|
||||
else:
|
||||
new_addrs.append(formataddr((contact.name, contact.website_email)))
|
||||
|
||||
|
|
Loading…
Reference in a new issue