FEATURE: Watched Words: when posts contain words, do one of flag, require approval, censor, or block

This commit is contained in:
Neil Lalonde
2017-06-28 16:56:44 -04:00
parent 9d774a951a
commit 24cb950432
49 changed files with 1096 additions and 37 deletions

View File

@@ -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

View 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

View File

@@ -0,0 +1,7 @@
class WatchedWordSerializer < ApplicationSerializer
attributes :id, :word, :action
def action
WatchedWord.actions[object.action]
end
end