mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
26 lines
601 B
Ruby
26 lines
601 B
Ruby
# frozen_string_literal: true
|
|
|
|
# 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
|