1
0
Fork 0
forked from gitea/nas
nas/app/models/admin/ng_word.rb
2023-07-25 15:17:23 +09:00

28 lines
603 B
Ruby

# frozen_string_literal: true
class Admin::NgWord
class << self
def reject?(text)
ng_words.any? { |word| text.include?(word) }
end
def hashtag_reject?(hashtag_count)
post_hash_tags_max.positive? && post_hash_tags_max < hashtag_count
end
def hashtag_reject_with_extractor?(text)
hashtag_reject?(Extractor.extract_hashtags(text)&.size || 0)
end
private
def ng_words
Setting.ng_words || []
end
def post_hash_tags_max
value = Setting.post_hash_tags_max
value.is_a?(Integer) && value.positive? ? value : 0
end
end
end