0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/plugins/discourse-narrative-bot/app/jobs/regular/send_default_welcome_message.rb
Jarek Radosz e372355fd0
DEV: Clean up scope resolution operators in plugins (#34979)
Co-authored-by: Loïc Guitaut <loic@discourse.org>
2025-09-30 14:36:34 +02:00

28 lines
859 B
Ruby
Vendored

# frozen_string_literal: true
module Jobs
class SendDefaultWelcomeMessage < ::Jobs::Base
def execute(args)
if user = User.find_by(id: args[:user_id])
type = user.invited_by ? "welcome_invite" : "welcome_user"
params = SystemMessage.new(user).defaults
title = I18n.t("system_messages.#{type}.subject_template", params)
raw = I18n.t("system_messages.#{type}.text_body_template", params)
discobot_user = DiscourseNarrativeBot::Base.new.discobot_user
post =
PostCreator.create!(
discobot_user,
title: title,
raw: raw,
archetype: Archetype.private_message,
target_usernames: user.username,
skip_validations: true,
)
post.topic.update_status("closed", true, discobot_user)
end
end
end
end