2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

FIX: invalid html in notification emails when template has been customized

This commit is contained in:
Neil Lalonde 2017-05-10 14:01:26 -04:00
parent 41fb76cc66
commit 5be7a2dad4
3 changed files with 2 additions and 9 deletions

View file

@ -252,12 +252,10 @@ class UserNotifications < ActionMailer::Base
end end
def email_post_markdown(post, add_posted_by=false) def email_post_markdown(post, add_posted_by=false)
result = "[email-indent]\n" result = "#{post.raw}\n\n"
result << "#{post.raw}\n\n"
if add_posted_by if add_posted_by
result << "#{I18n.t('user_notifications.posted_by', username: post.username, post_date: post.created_at.strftime("%m/%d/%Y"))}\n\n" result << "#{I18n.t('user_notifications.posted_by', username: post.username, post_date: post.created_at.strftime("%m/%d/%Y"))}\n\n"
end end
result << "[/email-indent]\n"
result result
end end

View file

@ -51,8 +51,6 @@ module Email
end end
end end
@message.parts[0].body = @message.parts[0].body.to_s.gsub(/\[\/?email-indent\]/, '')
# Fix relative (ie upload) HTML links in markdown which do not work well in plain text emails. # Fix relative (ie upload) HTML links in markdown which do not work well in plain text emails.
# These are the links we add when a user uploads a file or image. # These are the links we add when a user uploads a file or image.
# Ideally we would parse general markdown into plain text, but that is almost an intractable problem. # Ideally we would parse general markdown into plain text, but that is almost an intractable problem.

View file

@ -186,10 +186,7 @@ module Email
def to_html def to_html
strip_classes_and_ids strip_classes_and_ids
replace_relative_urls replace_relative_urls
@fragment.to_html.tap do |result| @fragment.to_html
result.gsub!(/\[email-indent\]/, "<div style='margin-left: 15px'>")
result.gsub!(/\[\/email-indent\]/, "</div>")
end
end end
def strip_avatars_and_emojis def strip_avatars_and_emojis