set EmailLog.mailbox_id in forward and reply phase. A EmailLog for each mailbox in forward phase.
This commit is contained in:
parent
6b07be5677
commit
54942cdf65
|
@ -531,13 +531,11 @@ def handle_forward(envelope, msg: Message, rcpt_to: str) -> List[Tuple[bool, str
|
||||||
|
|
||||||
contact = get_or_create_contact(msg["From"], envelope.mail_from, alias)
|
contact = get_or_create_contact(msg["From"], envelope.mail_from, alias)
|
||||||
|
|
||||||
email_log = EmailLog.create(contact_id=contact.id, user_id=contact.user_id)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
if not alias.enabled:
|
if not alias.enabled:
|
||||||
LOG.d("%s is disabled, do not forward", alias)
|
LOG.d("%s is disabled, do not forward", alias)
|
||||||
email_log.blocked = True
|
EmailLog.create(
|
||||||
|
contact_id=contact.id, user_id=contact.user_id, blocked=True, commit=True
|
||||||
|
)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
# do not return 5** to allow user to receive emails later when alias is enabled
|
# do not return 5** to allow user to receive emails later when alias is enabled
|
||||||
return [(True, "250 Message accepted for delivery")]
|
return [(True, "250 Message accepted for delivery")]
|
||||||
|
@ -560,7 +558,6 @@ def handle_forward(envelope, msg: Message, rcpt_to: str) -> List[Tuple[bool, str
|
||||||
forward_email_to_mailbox(
|
forward_email_to_mailbox(
|
||||||
alias,
|
alias,
|
||||||
copy(msg),
|
copy(msg),
|
||||||
email_log,
|
|
||||||
contact,
|
contact,
|
||||||
envelope,
|
envelope,
|
||||||
mailbox,
|
mailbox,
|
||||||
|
@ -574,7 +571,6 @@ def handle_forward(envelope, msg: Message, rcpt_to: str) -> List[Tuple[bool, str
|
||||||
def forward_email_to_mailbox(
|
def forward_email_to_mailbox(
|
||||||
alias,
|
alias,
|
||||||
msg: Message,
|
msg: Message,
|
||||||
email_log: EmailLog,
|
|
||||||
contact: Contact,
|
contact: Contact,
|
||||||
envelope,
|
envelope,
|
||||||
mailbox,
|
mailbox,
|
||||||
|
@ -619,6 +615,10 @@ def forward_email_to_mailbox(
|
||||||
# so when user fixes the mailbox, the email can be delivered
|
# so when user fixes the mailbox, the email can be delivered
|
||||||
return False, "421 SL E14"
|
return False, "421 SL E14"
|
||||||
|
|
||||||
|
email_log = EmailLog.create(
|
||||||
|
contact_id=contact.id, user_id=user.id, mailbox=mailbox.id, commit=True
|
||||||
|
)
|
||||||
|
|
||||||
# Spam check
|
# Spam check
|
||||||
spam_status = ""
|
spam_status = ""
|
||||||
is_spam = False
|
is_spam = False
|
||||||
|
@ -847,7 +847,10 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
|
||||||
return True, "250 SL E11"
|
return True, "250 SL E11"
|
||||||
|
|
||||||
email_log = EmailLog.create(
|
email_log = EmailLog.create(
|
||||||
contact_id=contact.id, is_reply=True, user_id=contact.user_id
|
contact_id=contact.id,
|
||||||
|
is_reply=True,
|
||||||
|
user_id=contact.user_id,
|
||||||
|
mailbox_id=mailbox.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Spam check
|
# Spam check
|
||||||
|
|
Loading…
Reference in New Issue