2019-11-13 16:31:49 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Jobs
|
|
|
|
class SendAdvancedTutorialMessage < ::Jobs::Base
|
|
|
|
def execute(args)
|
|
|
|
user = User.find_by(id: args[:user_id])
|
2019-12-11 09:03:31 -05:00
|
|
|
return if user.nil?
|
2019-11-13 16:31:49 -05:00
|
|
|
|
2020-01-01 06:23:36 -05:00
|
|
|
raw = I18n.t("discourse_narrative_bot.tl2_promotion_message.text_body_template",
|
|
|
|
discobot_username: ::DiscourseNarrativeBot::Base.new.discobot_user.username,
|
|
|
|
reset_trigger: "#{::DiscourseNarrativeBot::TrackSelector.reset_trigger} #{::DiscourseNarrativeBot::AdvancedUserNarrative.reset_trigger}")
|
|
|
|
|
2019-11-13 16:31:49 -05:00
|
|
|
PostCreator.create!(
|
|
|
|
Discourse.system_user,
|
|
|
|
title: I18n.t("discourse_narrative_bot.tl2_promotion_message.subject_template"),
|
2020-01-01 06:23:36 -05:00
|
|
|
raw: raw,
|
2019-11-13 16:31:49 -05:00
|
|
|
archetype: Archetype.private_message,
|
|
|
|
target_usernames: user.username,
|
|
|
|
skip_validations: true
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|