Files
discourse/plugins/discourse-narrative-bot/autoload/jobs/send_advanced_tutorial_message.rb
Roman Rizzi c63e84dc62 FEATURE: Send a message to new TL2 users and point them to the advanced tutorial (#8335)
* FEATURE: Send a message to new TL2 users and point them to the advanced tutorial

* DEV: Use a method to find the discobot user
2019-11-13 18:31:49 -03:00

20 lines
611 B
Ruby

# frozen_string_literal: true
module Jobs
class SendAdvancedTutorialMessage < ::Jobs::Base
def execute(args)
user = User.find_by(id: args[:user_id])
raise Discourse::InvalidParameters.new(:user_id) if user.nil?
PostCreator.create!(
Discourse.system_user,
title: I18n.t("discourse_narrative_bot.tl2_promotion_message.subject_template"),
raw: I18n.t("discourse_narrative_bot.tl2_promotion_message.text_body_template"),
archetype: Archetype.private_message,
target_usernames: user.username,
skip_validations: true
)
end
end
end