mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 03:03:44 +08:00
427d54b2b0
Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. We no longer need to use Rails "require_dependency" anywhere and instead can just use standard Ruby patterns to require files. This is a far reaching change and we expect some followups here.
28 lines
802 B
Ruby
28 lines
802 B
Ruby
# 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 = User.find(-2)
|
|
|
|
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
|