mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: raise proper error if system message creation fails
FIX: skip validations when creating system messages
This commit is contained in:
parent
843f93594f
commit
dec40ea3cf
|
@ -23,13 +23,18 @@ class SystemMessage
|
|||
title = I18n.t("system_messages.#{type}.subject_template", params)
|
||||
raw = I18n.t("system_messages.#{type}.text_body_template", params)
|
||||
|
||||
post = PostCreator.create(Discourse.site_contact_user,
|
||||
creator = PostCreator.create(Discourse.site_contact_user,
|
||||
title: title,
|
||||
raw: raw,
|
||||
archetype: Archetype.private_message,
|
||||
target_usernames: @recipient.username,
|
||||
subtype: TopicSubtype.system_message)
|
||||
subtype: TopicSubtype.system_message,
|
||||
skip_validations: true)
|
||||
|
||||
post = creator.create
|
||||
if creator.errors.present?
|
||||
raise StandardError, creator.errors.to_s
|
||||
end
|
||||
|
||||
UserArchivedMessage.create!(user: Discourse.site_contact_user, topic: post.topic)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user