DEV: Add option to send system message to groups (#12256)

This commit is contained in:
Gerhard Schlager
2021-03-02 18:51:50 +01:00
committed by GitHub
parent 8fd46c04ea
commit a96a5db0fb
2 changed files with 5 additions and 4 deletions

View File

@ -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