mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:41:03 +08:00
DEV: let reply_by_email, visit_link_to_respond email strings be modified by plugins (#27133)
* DEV: allow reply_by_email, visit_link_to_respond strings to be modified by plugins * DEV: separate visit_link_to_respond and reply_by_email modifiers out
This commit is contained in:
@ -4,14 +4,13 @@
|
||||
# for the body and subject
|
||||
module Email
|
||||
class MessageBuilder
|
||||
attr_reader :template_args
|
||||
attr_reader :template_args, :reply_by_email_key
|
||||
|
||||
ALLOW_REPLY_BY_EMAIL_HEADER = "X-Discourse-Allow-Reply-By-Email"
|
||||
|
||||
def initialize(to, opts = nil)
|
||||
@to = to
|
||||
@opts = opts || {}
|
||||
|
||||
@template_args = {
|
||||
site_name: SiteSetting.title,
|
||||
email_prefix: SiteSetting.email_prefix.presence || SiteSetting.title,
|
||||
@ -19,12 +18,23 @@ module Email
|
||||
user_preferences_url: "#{Discourse.base_url}/my/preferences",
|
||||
hostname: Discourse.current_hostname,
|
||||
}.merge!(@opts)
|
||||
|
||||
if @template_args[:url].present?
|
||||
@template_args[:header_instructions] ||= I18n.t(
|
||||
"user_notifications.header_instructions",
|
||||
@template_args,
|
||||
)
|
||||
@visit_link_to_respond_key =
|
||||
DiscoursePluginRegistry.apply_modifier(
|
||||
:message_builder_visit_link_to_respond,
|
||||
"user_notifications.visit_link_to_respond",
|
||||
@opts,
|
||||
)
|
||||
@reply_by_email_key =
|
||||
DiscoursePluginRegistry.apply_modifier(
|
||||
:message_builder_reply_by_email,
|
||||
"user_notifications.reply_by_email",
|
||||
@opts,
|
||||
)
|
||||
|
||||
if @opts[:include_respond_instructions] == false
|
||||
@template_args[:respond_instructions] = ""
|
||||
@ -40,9 +50,9 @@ module Email
|
||||
string =
|
||||
(
|
||||
if allow_reply_by_email?
|
||||
+"user_notifications.reply_by_email"
|
||||
+@reply_by_email_key
|
||||
else
|
||||
+"user_notifications.visit_link_to_respond"
|
||||
+@visit_link_to_respond_key
|
||||
end
|
||||
)
|
||||
string << "_pm" if @opts[:private_reply]
|
||||
|
Reference in New Issue
Block a user