Add extended domain block tests

This commit is contained in:
KMY 2023-09-04 12:07:29 +09:00
parent 43144661ea
commit 7a0bf2e948
6 changed files with 231 additions and 15 deletions

View file

@ -48,8 +48,6 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
def create_status
return reject_payload! if unsupported_object_type? || non_matching_uri_hosts?(@account.uri, object_uri) || tombstone_exists? || !related_to_local_activity?
return reject_payload! if (reply_to_local? || reply_to_local_account?) && reject_reply_to_local?
return reject_payload! if (!reply_to_local_account_following? || !reply_to_local_status_following?) && reject_reply_exclude_followers?
with_redis_lock("create:#{object_uri}") do
return if delete_arrived_first?(object_uri) || poll_vote?
@ -63,7 +61,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
end
@status
@status || reject_payload!
end
def audience_to
@ -90,7 +88,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
process_tags
process_audience
return unless valid_status?
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?
ApplicationRecord.transaction do
@status = Status.create!(@params)
@ -148,14 +148,6 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
!Admin::NgWord.reject?("#{@params[:spoiler_text]}\n#{@params[:text]}") && !Admin::NgWord.hashtag_reject?(@tags.size)
end
def reply_to_local_account?
accounts_in_audience.any?(&:local?)
end
def reply_to_local_account_following?
!reply_to_local_account? || accounts_in_audience.none? { |account| account.local? && !account.following?(@account) }
end
def accounts_in_audience
return @accounts_in_audience if @accounts_in_audience
@ -420,6 +412,22 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
@skip_download ||= DomainBlock.reject_media?(@account.domain)
end
def reply_to_local_account?
accounts_in_audience.any?(&:local?)
end
def reply_to_local_account_following?
!reply_to_local_account? || accounts_in_audience.none? { |account| account.local? && !account.following?(@account) }
end
def reply_to_local_from_tags?
(@mentions.nil? || @mentions.any? { |m| m.account.local? })
end
def reply_to_local_from_tags_following?
(@mentions.nil? || @mentions.none? { |m| m.account.local? && !m.account.following?(@account) })
end
def reply_to_local?
!replied_to_status.nil? && replied_to_status.account.local?
end