mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05: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
1 changed files with 7 additions and 2 deletions
|
@ -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 a new issue