Jelajahi Sumber

log more info

Son NK 5 tahun lalu
induk
melakukan
f577adc0d4
1 mengubah file dengan 8 tambahan dan 4 penghapusan
  1. 8 4
      email_handler.py

+ 8 - 4
email_handler.py

@@ -701,34 +701,38 @@ def handle_bounce(contact: Contact, alias: Alias, msg: Message, user: User):
     nb_bounced = EmailLog.filter_by(contact_id=contact.id, bounced=True).count()
     disable_alias_link = f"{URL}/dashboard/unsubscribe/{alias.id}"
 
-    # Store the bounced email
-    orig_msg = get_orig_message_from_bounce(msg)
+    # <<< Store the bounced email >>>
     # generate a name for the email
     random_name = str(uuid.uuid4())
 
     full_report_path = f"refused-emails/full-{random_name}.eml"
     s3.upload_email_from_bytesio(full_report_path, BytesIO(msg.as_bytes()), random_name)
 
+    orig_msg = get_orig_message_from_bounce(msg)
     if not orig_msg:
         LOG.error(
-            "Cannot parse original message from bounce message %s %s %s",
+            "Cannot parse original message from bounce message %s %s %s %s",
             alias,
             user,
             contact,
+            full_report_path,
         )
         return
 
     file_path = f"refused-emails/{random_name}.eml"
     s3.upload_email_from_bytesio(file_path, BytesIO(orig_msg.as_bytes()), random_name)
+    # <<< END Store the bounced email >>>
+
     mailbox_id = int(orig_msg[_MAILBOX_ID_HEADER])
     mailbox = Mailbox.get(mailbox_id)
     if not mailbox or mailbox.user_id != user.id:
         LOG.error(
-            "Tampered message mailbox_id %s, %s, %s, %s",
+            "Tampered message mailbox_id %s, %s, %s, %s %s",
             mailbox_id,
             user,
             alias,
             contact,
+            full_report_path,
         )
         return