瀏覽代碼

display mailbox that a bounce affects

Son NK 5 年之前
父節點
當前提交
bc55b98e12
共有 3 個文件被更改,包括 9 次插入4 次删除
  1. 1 1
      app/dashboard/templates/dashboard/alias_log.html
  2. 2 3
      app/dashboard/views/alias_log.py
  3. 6 0
      app/models.py

+ 1 - 1
app/dashboard/templates/dashboard/alias_log.html

@@ -129,7 +129,7 @@
               <img src="{{ url_for('static', filename='arrows/forward-arrow.svg') }}" class="arrow">
               <span class="ml-2">{{ log.alias }}</span>
               <img src="{{ url_for('static', filename='arrows/blocked-arrow.svg') }}" class="arrow">
-              <span class="ml-2">{{ log.mailbox }}</span>
+              <span class="ml-2">{{ log.email_log.bounced_mailbox() }}</span>
             </div>
           {% else %}
             <div>

+ 2 - 3
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)

+ 6 - 0
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: