mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Add subtype to topics to classify private messages
This commit is contained in:
parent
2b5a2b5fce
commit
3b6aeb14c7
16 changed files with 223 additions and 43 deletions
52
lib/topic_subtype.rb
Normal file
52
lib/topic_subtype.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
class TopicSubtype
|
||||
include ActiveModel::Serialization
|
||||
|
||||
attr_accessor :id, :options
|
||||
|
||||
def initialize(id, options)
|
||||
@id = id
|
||||
@options = options
|
||||
end
|
||||
|
||||
def attributes
|
||||
{'id' => @id,
|
||||
'options' => @options}
|
||||
end
|
||||
|
||||
def self.list
|
||||
return [] unless @archetypes.present?
|
||||
@archetypes.values
|
||||
end
|
||||
|
||||
def self.user_to_user
|
||||
'user_to_user'
|
||||
end
|
||||
|
||||
def self.system_message
|
||||
'system_message'
|
||||
end
|
||||
|
||||
def self.moderator_warning
|
||||
'moderator_warning'
|
||||
end
|
||||
|
||||
def self.notify_moderators
|
||||
'notify_moderators'
|
||||
end
|
||||
|
||||
def self.notify_user
|
||||
'notify_user'
|
||||
end
|
||||
|
||||
def self.register(name, options={})
|
||||
@subtypes ||= {}
|
||||
@subtypes[name] = TopicSubtype.new(name, options)
|
||||
end
|
||||
|
||||
register 'user_to_user'
|
||||
register 'system_message'
|
||||
register 'moderator_warning'
|
||||
register 'notify_moderators'
|
||||
register 'notify_user'
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue