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

This commit is contained in:
Son NK 2020-08-21 10:41:50 +02:00
parent 5bb4c20fba
commit 2b2512e775
1 changed files with 13 additions and 2 deletions

View File

@ -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