mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 13:14:48 +08:00
More extensibility for custom silence/suspend messages
This commit is contained in:
23
lib/staff_message_format.rb
Normal file
23
lib/staff_message_format.rb
Normal file
@ -0,0 +1,23 @@
|
||||
# This is used for formatting Suspension/Silencing messages.
|
||||
# It can be extended by plugins to provide custom message formats.
|
||||
class StaffMessageFormat
|
||||
def initialize(type, reason, message = nil)
|
||||
@type = type
|
||||
@reason = reason
|
||||
@message = message
|
||||
|
||||
after_initialize
|
||||
end
|
||||
|
||||
# Plugins can overwrite this to munge values before formatting
|
||||
def after_initialize
|
||||
end
|
||||
|
||||
# Overwrite this to change formatting
|
||||
def format
|
||||
result = ""
|
||||
result << @reason if @reason.present?
|
||||
result << "\n\n#{@message}" if @message.present?
|
||||
result
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user