mirror of
https://github.com/discourse/discourse.git
synced 2025-08-20 18:52:44 +08:00
FIX: TL2 promotion message from discobot didn't use user locale
Includes a small refactor/fix, because `return` isn't allowed in blocks.
This commit is contained in:
parent
bbcd70e8b5
commit
ae744693d8
2 changed files with 25 additions and 7 deletions
|
@ -300,15 +300,17 @@ after_initialize do
|
|||
)
|
||||
|
||||
self.on(:system_message_sent) do |args|
|
||||
if args[:message_type] == 'tl2_promotion_message' && SiteSetting.discourse_narrative_bot_enabled
|
||||
next if !SiteSetting.discourse_narrative_bot_enabled
|
||||
next if args[:message_type] != 'tl2_promotion_message'
|
||||
|
||||
recipient = args[:post].topic.topic_users.where.not(user_id: args[:post].user_id).last&.user
|
||||
recipient ||= Discourse.site_contact_user if args[:post].user == Discourse.site_contact_user
|
||||
next if recipient.nil?
|
||||
|
||||
I18n.with_locale(recipient.effective_locale) do
|
||||
raw = I18n.t("discourse_narrative_bot.tl2_promotion_message.text_body_template",
|
||||
discobot_username: ::DiscourseNarrativeBot::Base.new.discobot_username,
|
||||
reset_trigger: "#{::DiscourseNarrativeBot::TrackSelector.reset_trigger} #{::DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}")
|
||||
|
||||
recipient = args[:post].topic.topic_users.where.not(user_id: args[:post].user_id).last&.user
|
||||
recipient ||= Discourse.site_contact_user if args[:post].user == Discourse.site_contact_user
|
||||
return if recipient.nil?
|
||||
discobot_username: ::DiscourseNarrativeBot::Base.new.discobot_username,
|
||||
reset_trigger: "#{::DiscourseNarrativeBot::TrackSelector.reset_trigger} #{::DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}")
|
||||
|
||||
PostCreator.create!(
|
||||
::DiscourseNarrativeBot::Base.new.discobot_user,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue