Regexp is available in ng_words
This commit is contained in:
parent
1c15ccb6b2
commit
266823643e
4 changed files with 29 additions and 2 deletions
|
@ -3,7 +3,11 @@
|
|||
class Admin::NgWord
|
||||
class << self
|
||||
def reject?(text)
|
||||
ng_words.any? { |word| text.include?(word) }
|
||||
ng_words.any? { |word| include?(text, word) }
|
||||
end
|
||||
|
||||
def reject_with_custom_words?(text, custom_ng_words)
|
||||
custom_ng_words.any? { |word| include?(text, word) }
|
||||
end
|
||||
|
||||
def hashtag_reject?(hashtag_count)
|
||||
|
@ -16,6 +20,14 @@ class Admin::NgWord
|
|||
|
||||
private
|
||||
|
||||
def include?(text, word)
|
||||
if word.start_with?('?') && word.size >= 2
|
||||
text =~ /#{word[1..]}/i
|
||||
else
|
||||
text.include?(word)
|
||||
end
|
||||
end
|
||||
|
||||
def ng_words
|
||||
Setting.ng_words || []
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue