Add domain block setting reject_favourite and reject_reply

This commit is contained in:
KMY 2023-04-27 12:04:10 +09:00
parent 27353bbaee
commit 6537405eab
15 changed files with 85 additions and 22 deletions

View file

@ -46,6 +46,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? && reject_reply_to_local?
with_lock("create:#{object_uri}") do
return if delete_arrived_first?(object_uri) || poll_vote?
@ -392,6 +393,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
!replied_to_status.nil? && replied_to_status.account.local?
end
def reject_reply_to_local?
@reject_reply_to_local ||= DomainBlock.reject_reply?(@account.domain)
end
def related_to_local_activity?
fetch? || followed_by_local_accounts? || requested_through_relay? ||
responds_to_followed_account? || addresses_local_accounts?

View file

@ -4,7 +4,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
def perform
@original_status = status_from_uri(object_uri)
return if @original_status.nil? || !@original_status.account.local? || delete_arrived_first?(@json['id'])
return if @original_status.nil? || !@original_status.account.local? || delete_arrived_first?(@json['id']) || reject_favourite?
if shortcode.nil?
process_favourite
@ -15,6 +15,10 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
private
def reject_favourite?
@reject_favourite ||= DomainBlock.reject_favourite?(@account.domain)
end
def process_favourite
return if @account.favourited?(@original_status)