Fix recreate alias from trash (#1641)

* no need to check for a deleted alias that belongs to user domain

* fix config.SAVE_UNSENT_DIR not set
This commit is contained in:
Son Nguyen Kim 2023-03-17 15:39:59 +01:00 committed by GitHub
parent 26d5fd400c
commit b6286e3c1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 13 deletions

View file

@ -120,18 +120,11 @@ def custom_alias():
email=full_alias
)
custom_domain = domain_deleted_alias.domain
if domain_deleted_alias.user_id == current_user.id:
flash(
f"You have deleted this alias before. You can restore it on "
f"{custom_domain.domain} 'Deleted Alias' page",
"error",
)
else:
# should never happen as user can only choose their domains
LOG.e(
"Deleted Alias %s does not belong to user %s",
domain_deleted_alias,
)
flash(
f"You have deleted this alias before. You can restore it on "
f"{custom_domain.domain} 'Deleted Alias' page",
"error",
)
elif DeletedAlias.get_by(email=full_alias):
flash(general_error_msg, "error")

View file

@ -170,7 +170,8 @@ class MailSender:
LOG.e(
f"Could not send message to smtp server {config.POSTFIX_SERVER}:{config.POSTFIX_PORT}"
)
self._save_request_to_unsent_dir(send_request)
if config.SAVE_UNSENT_DIR:
self._save_request_to_unsent_dir(send_request)
return False
def _save_request_to_unsent_dir(