mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 17:06:31 -06:00
DEV: Add option to send system message to groups (#12256)
This commit is contained in:
parent
8fd46c04ea
commit
a96a5db0fb
@ -26,12 +26,12 @@ module Jobs
|
||||
end
|
||||
|
||||
def notify_user(ex)
|
||||
post = SystemMessage.create_from_system_user(
|
||||
SystemMessage.create_from_system_user(
|
||||
Discourse.system_user,
|
||||
:backup_failed,
|
||||
target_group_names: Group[:admins].name,
|
||||
logs: "#{ex}\n" + ex.backtrace.join("\n")
|
||||
)
|
||||
post.topic.invite_group(Discourse.system_user, Group[:admins])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -18,15 +18,16 @@ class SystemMessage
|
||||
end
|
||||
|
||||
def create(type, params = {})
|
||||
from_system = params.delete(:from_system)
|
||||
target_group_names = params.delete(:target_group_names)
|
||||
|
||||
params = defaults.merge(params)
|
||||
from_system = params[:from_system] || false
|
||||
|
||||
title = params[:message_title] || I18n.with_locale(@recipient.effective_locale) { I18n.t("system_messages.#{type}.subject_template", params) }
|
||||
raw = params[:message_raw] || I18n.with_locale(@recipient.effective_locale) { I18n.t("system_messages.#{type}.text_body_template", params) }
|
||||
|
||||
if from_system
|
||||
user = Discourse.system_user
|
||||
target_group_names = nil
|
||||
else
|
||||
user = Discourse.site_contact_user
|
||||
target_group_names = Group.exists?(name: SiteSetting.site_contact_group_name) ? SiteSetting.site_contact_group_name : nil
|
||||
|
Loading…
Reference in New Issue
Block a user