mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 22:16:25 +08:00
FIX: sending email wasn't working anymore when a plugin used 'reduce_cooked' (cc @gdpelican)
This commit is contained in:
parent
feffe23cc5
commit
c012b18601
@ -65,9 +65,9 @@ module UserNotificationsHelper
|
|||||||
normalize_name(post.user.name) != normalize_name(post.user.username)
|
normalize_name(post.user.name) != normalize_name(post.user.username)
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_for_email(post, use_excerpt, style: nil)
|
def format_for_email(post, use_excerpt, style = nil)
|
||||||
html = use_excerpt ? post.excerpt : post.cooked
|
html = use_excerpt ? post.excerpt : post.cooked
|
||||||
PrettyText.format_for_email(html, post, style: style).html_safe
|
PrettyText.format_for_email(html, post, style).html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
<span> - </span>
|
<span> - </span>
|
||||||
<span><%= I18n.l(post.created_at, format: :long) %></span>
|
<span><%= I18n.l(post.created_at, format: :long) %></span>
|
||||||
</p>
|
</p>
|
||||||
<%= raw format_for_email(post, false, style: :notification) %>
|
<%= raw format_for_email(post, false, :notification) %>
|
||||||
<hr />
|
<hr />
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -6,6 +6,10 @@ module Email
|
|||||||
class Styles
|
class Styles
|
||||||
@@plugin_callbacks = []
|
@@plugin_callbacks = []
|
||||||
|
|
||||||
|
attr_accessor :fragment
|
||||||
|
|
||||||
|
delegate :css, to: :fragment
|
||||||
|
|
||||||
def initialize(html, opts=nil)
|
def initialize(html, opts=nil)
|
||||||
@html = html
|
@html = html
|
||||||
@opts = opts || {}
|
@opts = opts || {}
|
||||||
|
@ -390,11 +390,11 @@ module PrettyText
|
|||||||
doc.css(".lightbox-wrapper .meta").remove
|
doc.css(".lightbox-wrapper .meta").remove
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.format_for_email(html, post = nil, style: nil)
|
def self.format_for_email(html, post = nil, style = nil)
|
||||||
Email::Styles.new(html, style: style).tap do |doc|
|
Email::Styles.new(html, style: style).tap do |doc|
|
||||||
|
DiscourseEvent.trigger(:reduce_cooked, doc, post)
|
||||||
doc.make_all_links_absolute
|
doc.make_all_links_absolute
|
||||||
doc.send :"format_#{style}" if style
|
doc.send :"format_#{style}" if style
|
||||||
DiscourseEvent.trigger(:reduce_cooked, doc, post)
|
|
||||||
end.to_html
|
end.to_html
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user