mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
email mirror: make being one of many recipients okay.
Previously the email gateway had to be the only address in a recipient field or we'd mis-parse the recipient. This commit also makes the mirror correctly handle addresses of the form "Jessica McKellar <jesstess@zulip.com>". (imported from commit 7435f2b59b8f47dc599cc869f64597a730af7d12)
This commit is contained in:
@@ -18,6 +18,7 @@ Run this management command out of a cron job.
|
|||||||
import email
|
import email
|
||||||
from os import path
|
from os import path
|
||||||
from email.header import decode_header
|
from email.header import decode_header
|
||||||
|
from email.utils import getaddresses
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@@ -159,9 +160,11 @@ def delete(result, proto):
|
|||||||
def find_emailgateway_recipient(message):
|
def find_emailgateway_recipient(message):
|
||||||
# We can't use Delivered-To; that is emailgateway@zulip.com.
|
# We can't use Delivered-To; that is emailgateway@zulip.com.
|
||||||
for header in ("To", "Cc", "Bcc"):
|
for header in ("To", "Cc", "Bcc"):
|
||||||
recipient = message.get(header)
|
recipients = getaddresses(message.get_all(header, []))
|
||||||
if recipient and recipient.lower().endswith("@streams.zulip.com"):
|
for recipient_name, recipient_email in recipients:
|
||||||
return recipient
|
if recipient_email.lower().endswith("@streams.zulip.com"):
|
||||||
|
return recipient_email
|
||||||
|
|
||||||
raise ZulipEmailForwardError("Missing recipient @streams.zulip.com")
|
raise ZulipEmailForwardError("Missing recipient @streams.zulip.com")
|
||||||
|
|
||||||
def fetch(result, proto, mailboxes):
|
def fetch(result, proto, mailboxes):
|
||||||
|
|||||||
Reference in New Issue
Block a user