* Add: フォローしていないアカウントからのリプライのNGワード * Test: ハッシュタグ使用量
This commit is contained in:
parent
da662d2f84
commit
3a2030dfc8
8 changed files with 223 additions and 5 deletions
|
@ -32,7 +32,7 @@ module Admin
|
|||
private
|
||||
|
||||
def test_words
|
||||
ng_words = settings_params['ng_words'].split(/\r\n|\r|\n/)
|
||||
ng_words = "#{settings_params['ng_words']}\n#{settings_params['ng_words_for_stranger_mention']}".split(/\r\n|\r|\n/).filter(&:present?)
|
||||
Admin::NgWord.reject_with_custom_words?('Sample text', ng_words)
|
||||
end
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
|
||||
return nil unless valid_status?
|
||||
return nil if (reply_to_local? || reply_to_local_account? || reply_to_local_from_tags?) && reject_reply_to_local?
|
||||
return nil if (!reply_to_local_account_following? || !reply_to_local_status_following? || !reply_to_local_from_tags_following?) && reject_reply_exclude_followers?
|
||||
return nil if mention_to_local_but_not_followed? && reject_reply_exclude_followers?
|
||||
|
||||
ApplicationRecord.transaction do
|
||||
@status = Status.create!(@params)
|
||||
|
@ -139,7 +139,11 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
end
|
||||
|
||||
def valid_status?
|
||||
!Admin::NgWord.reject?("#{@params[:spoiler_text]}\n#{@params[:text]}") && !Admin::NgWord.hashtag_reject?(@tags.size)
|
||||
valid = !Admin::NgWord.reject?("#{@params[:spoiler_text]}\n#{@params[:text]}") && !Admin::NgWord.hashtag_reject?(@tags.size)
|
||||
|
||||
valid = !Admin::NgWord.stranger_mention_reject?("#{@params[:spoiler_text]}\n#{@params[:text]}") if valid && mention_to_local_but_not_followed?
|
||||
|
||||
valid
|
||||
end
|
||||
|
||||
def accounts_in_audience
|
||||
|
@ -418,11 +422,11 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
end
|
||||
|
||||
def reply_to_local_from_tags?
|
||||
(@mentions.present? && @mentions.any? { |m| m.account.local? })
|
||||
@mentions.present? && @mentions.any? { |m| m.account.local? }
|
||||
end
|
||||
|
||||
def reply_to_local_from_tags_following?
|
||||
(@mentions.present? && @mentions.none? { |m| m.account.local? && !m.account.following?(@account) })
|
||||
@mentions.nil? || @mentions.none? { |m| m.account.local? && !m.account.following?(@account) }
|
||||
end
|
||||
|
||||
def reply_to_local?
|
||||
|
@ -433,6 +437,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
!reply_to_local? || replied_to_status.account.following?(@account)
|
||||
end
|
||||
|
||||
def mention_to_local_but_not_followed?
|
||||
!reply_to_local_account_following? || !reply_to_local_status_following? || !reply_to_local_from_tags_following?
|
||||
end
|
||||
|
||||
def reject_reply_to_local?
|
||||
@reject_reply_to_local ||= DomainBlock.reject_reply?(@account.domain)
|
||||
end
|
||||
|
|
|
@ -18,6 +18,10 @@ class Admin::NgWord
|
|||
hashtag_reject?(Extractor.extract_hashtags(text)&.size || 0)
|
||||
end
|
||||
|
||||
def stranger_mention_reject?(text)
|
||||
ng_words_for_stranger_mention.any? { |word| include?(text, word) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def include?(text, word)
|
||||
|
@ -32,6 +36,10 @@ class Admin::NgWord
|
|||
Setting.ng_words || []
|
||||
end
|
||||
|
||||
def ng_words_for_stranger_mention
|
||||
Setting.ng_words_for_stranger_mention || []
|
||||
end
|
||||
|
||||
def post_hash_tags_max
|
||||
value = Setting.post_hash_tags_max
|
||||
value.is_a?(Integer) && value.positive? ? value : 0
|
||||
|
|
|
@ -38,6 +38,7 @@ class Form::AdminSettings
|
|||
status_page_url
|
||||
captcha_enabled
|
||||
ng_words
|
||||
ng_words_for_stranger_mention
|
||||
hide_local_users_for_anonymous
|
||||
post_hash_tags_max
|
||||
sensitive_words
|
||||
|
@ -91,6 +92,7 @@ class Form::AdminSettings
|
|||
|
||||
STRING_ARRAY_KEYS = %i(
|
||||
ng_words
|
||||
ng_words_for_stranger_mention
|
||||
sensitive_words
|
||||
sensitive_words_for_full
|
||||
).freeze
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
= simple_form_for @admin_settings, url: admin_ng_words_path, html: { method: :post } do |f|
|
||||
= render 'shared/error_messages', object: @admin_settings
|
||||
|
||||
.fields-group
|
||||
= f.input :ng_words_for_stranger_mention, wrapper: :with_label, as: :text, input_html: { rows: 12 }, label: t('admin.ng_words.keywords_for_stranger_mention'), hint: t('admin.ng_words.keywords_for_stranger_mention_hint')
|
||||
|
||||
.fields-group
|
||||
= f.input :ng_words, wrapper: :with_label, as: :text, input_html: { rows: 12 }, label: t('admin.ng_words.keywords'), hint: t('admin.ng_words.keywords_hint')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue