mirror of https://github.com/zulip/zulip.git
Filter obvious footers from email mirror messages.
(imported from commit 7e22b6823b5d0a07f7f350e4af65be66728a8f88)
This commit is contained in:
parent
0d6ad56c29
commit
6afdfeb1dc
|
@ -157,6 +157,17 @@ def extract_body(message):
|
||||||
|
|
||||||
raise ZulipEmailForwardError("Unable to find plaintext or HTML message body")
|
raise ZulipEmailForwardError("Unable to find plaintext or HTML message body")
|
||||||
|
|
||||||
|
def filter_footer(text):
|
||||||
|
# Try to filter out obvious footers.
|
||||||
|
possible_footers = filter(lambda line: line.strip().startswith("--"),
|
||||||
|
text.split("\n"))
|
||||||
|
if len(possible_footers) != 1:
|
||||||
|
# Be conservative and don't try to scrub content if there
|
||||||
|
# isn't a trivial footer structure.
|
||||||
|
return text
|
||||||
|
|
||||||
|
return text.partition("--")[0].strip()
|
||||||
|
|
||||||
def extract_and_upload_attachments(message):
|
def extract_and_upload_attachments(message):
|
||||||
attachment_links = []
|
attachment_links = []
|
||||||
|
|
||||||
|
@ -225,7 +236,7 @@ def fetch(result, proto, mailboxes):
|
||||||
debug_info = {}
|
debug_info = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
body = extract_body(message)
|
body = filter_footer(extract_body(message))
|
||||||
to = find_emailgateway_recipient(message)
|
to = find_emailgateway_recipient(message)
|
||||||
debug_info["to"] = to
|
debug_info["to"] = to
|
||||||
stream = extract_and_validate(to)
|
stream = extract_and_validate(to)
|
||||||
|
|
Loading…
Reference in New Issue