mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Watched Words: when posts contain words, do one of flag, require approval, censor, or block
This commit is contained in:
@@ -25,7 +25,8 @@ class SiteSerializer < ApplicationSerializer
|
||||
:top_tags,
|
||||
:wizard_required,
|
||||
:topic_featured_link_allowed_category_ids,
|
||||
:user_themes
|
||||
:user_themes,
|
||||
:censored_words
|
||||
|
||||
has_many :categories, serializer: BasicCategorySerializer, embed: :objects
|
||||
has_many :trust_levels, embed: :objects
|
||||
@@ -142,4 +143,8 @@ class SiteSerializer < ApplicationSerializer
|
||||
def topic_featured_link_allowed_category_ids
|
||||
scope.topic_featured_link_allowed_category_ids
|
||||
end
|
||||
|
||||
def censored_words
|
||||
WordWatcher.words_for_action(:censor).join('|')
|
||||
end
|
||||
end
|
||||
|
||||
13
app/serializers/watched_word_list_serializer.rb
Normal file
13
app/serializers/watched_word_list_serializer.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class WatchedWordListSerializer < ApplicationSerializer
|
||||
attributes :actions, :words
|
||||
|
||||
def actions
|
||||
WatchedWord.actions.keys
|
||||
end
|
||||
|
||||
def words
|
||||
object.map do |word|
|
||||
WatchedWordSerializer.new(word, root: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
7
app/serializers/watched_word_serializer.rb
Normal file
7
app/serializers/watched_word_serializer.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class WatchedWordSerializer < ApplicationSerializer
|
||||
attributes :id, :word, :action
|
||||
|
||||
def action
|
||||
WatchedWord.actions[object.action]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user