Add: メンション数上限 (#565)

* Add: メンション数上限

* Fix test
This commit is contained in:
KMY(雪あすか) 2024-02-17 09:50:06 +09:00 committed by GitHub
parent 5424567aef
commit 7411941885
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 94 additions and 5 deletions

View file

@ -26,6 +26,14 @@ class Admin::NgWord
hashtag_reject?(Extractor.extract_hashtags(text)&.size || 0)
end
def mention_reject?(mention_count)
post_mentions_max.positive? && post_mentions_max < mention_count
end
def mention_reject_with_extractor?(text)
mention_reject?(text.gsub(Account::MENTION_RE)&.count || 0)
end
private
def include?(text, word)
@ -49,6 +57,11 @@ class Admin::NgWord
value.is_a?(Integer) && value.positive? ? value : 0
end
def post_mentions_max
value = Setting.post_mentions_max
value.is_a?(Integer) && value.positive? ? value : 0
end
def record!(type, text, keyword, options)
return unless options[:uri] && options[:target_type]
return if options.key?(:public) && !options.delete(:public)