Add domainblocks to reject_reply_exclude_followers

This commit is contained in:
KMY 2023-05-12 21:46:28 +09:00
parent f84a002675
commit 3fa8efaf93
12 changed files with 50 additions and 9 deletions

View file

@ -47,6 +47,7 @@ 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?
@ -141,6 +142,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
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
@ -403,10 +408,18 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
!replied_to_status.nil? && replied_to_status.account.local?
end
def reply_to_local_status_following?
!reply_to_local? || replied_to_status.account.following?(@account)
end
def reject_reply_to_local?
@reject_reply_to_local ||= DomainBlock.reject_reply?(@account.domain)
end
def reject_reply_exclude_followers?
@reject_reply_exclude_followers ||= DomainBlock.reject_reply_exclude_followers?(@account.domain)
end
def ignore_hashtags?
@ignore_hashtags ||= DomainBlock.reject_hashtag?(@account.domain)
end