Przeglądaj źródła

no need to create a copy of message when there's only 1 mailbox

Son NK 4 lat temu
rodzic
commit
2b2512e775
1 zmienionych plików z 13 dodań i 2 usunięć
  1. 13 2
      email_handler.py

+ 13 - 2
email_handler.py

@@ -397,12 +397,23 @@ async def handle_forward(
     user = alias.user
     user = alias.user
 
 
     ret = []
     ret = []
-    for mailbox in alias.mailboxes:
+    mailboxes = alias.mailboxes
+    # no need to create a copy of message
+    if len(mailboxes) == 1:
+        mailbox = mailboxes[0]
         ret.append(
         ret.append(
             await forward_email_to_mailbox(
             await forward_email_to_mailbox(
-                alias, copy(msg), email_log, contact, envelope, smtp, mailbox, user
+                alias, msg, email_log, contact, envelope, smtp, mailbox, user
             )
             )
         )
         )
+    # create a copy of message for each forward
+    else:
+        for mailbox in mailboxes:
+            ret.append(
+                await forward_email_to_mailbox(
+                    alias, copy(msg), email_log, contact, envelope, smtp, mailbox, user
+                )
+            )
 
 
     return ret
     return ret