diff --git a/app/dashboard/templates/dashboard/alias_log.html b/app/dashboard/templates/dashboard/alias_log.html index 66cc21d3..40a3b6bb 100644 --- a/app/dashboard/templates/dashboard/alias_log.html +++ b/app/dashboard/templates/dashboard/alias_log.html @@ -129,7 +129,7 @@ {{ log.alias }} - {{ log.mailbox }} + {{ log.email_log.bounced_mailbox() }} {% else %}
diff --git a/app/dashboard/views/alias_log.py b/app/dashboard/views/alias_log.py index e86a602b..56be2cb4 100644 --- a/app/dashboard/views/alias_log.py +++ b/app/dashboard/views/alias_log.py @@ -16,7 +16,7 @@ class AliasLog: is_reply: bool blocked: bool bounced: bool - mailbox: str + email_log: EmailLog def __init__(self, **kwargs): for k, v in kwargs.items(): @@ -63,7 +63,6 @@ def alias_log(alias_id, page_id): def get_alias_log(alias: Alias, page_id=0) -> [AliasLog]: logs: [AliasLog] = [] - mailbox = alias.mailbox_email() q = ( db.session.query(Contact, EmailLog) @@ -83,7 +82,7 @@ def get_alias_log(alias: Alias, page_id=0) -> [AliasLog]: is_reply=email_log.is_reply, blocked=email_log.blocked, bounced=email_log.bounced, - mailbox=mailbox, + email_log=email_log, ) logs.append(al) logs = sorted(logs, key=lambda l: l.when, reverse=True) diff --git a/app/models.py b/app/models.py index 44cc4618..aa8f3434 100644 --- a/app/models.py +++ b/app/models.py @@ -934,6 +934,12 @@ class EmailLog(db.Model, ModelMixin): contact = db.relationship(Contact) + def bounced_mailbox(self) -> str: + if self.bounced_mailbox_id: + return Mailbox.get(self.bounced_mailbox_id).email + # retro-compatibility + return self.contact.alias.mailboxes[0].email + def get_action(self) -> str: """return the action name: forward|reply|block|bounced""" if self.is_reply: