mirror of
https://github.com/discourse/discourse.git
synced 2025-03-04 02:27:41 +08:00
Add support to elide content from ProtonMail emails
This commit is contained in:
parent
67efdaea40
commit
a0386655a6
@ -301,6 +301,7 @@ module Email
|
||||
[:exchange, /name="message(Body|Reply)Section"/],
|
||||
[:apple_mail, /id="AppleMailSignature"/],
|
||||
[:mozilla, /class="moz-/],
|
||||
[:protonmail, /class="protonmail_/],
|
||||
]
|
||||
|
||||
def extract_from_gmail(html)
|
||||
@ -351,6 +352,13 @@ module Email
|
||||
to_markdown(doc.to_html, elided.to_html)
|
||||
end
|
||||
|
||||
def extract_from_protonmail(html)
|
||||
doc = Nokogiri::HTML.fragment(html)
|
||||
# Removes anything that has a class starting with "protonmail_" and everything after that
|
||||
elided = doc.css("*[class^='protonmail_'], *[class^='protonmail_'] ~ *").remove
|
||||
to_markdown(doc.to_html, elided.to_html)
|
||||
end
|
||||
|
||||
def trim_reply_and_extract_elided(text)
|
||||
return [text, ""] if @opts[:skip_trimming]
|
||||
EmailReplyTrimmer.trim(text, true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user