Addo domein block extra supports
This commit is contained in:
parent
bb7fa1d060
commit
9ad92e6a09
24 changed files with 331 additions and 35 deletions
|
@ -215,7 +215,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
end
|
||||
|
||||
def process_hashtag(tag)
|
||||
return if tag['name'].blank?
|
||||
return if tag['name'].blank? || ignore_hashtags?
|
||||
|
||||
Tag.find_or_create_by_names(tag['name']) do |hashtag|
|
||||
@tags << hashtag unless @tags.include?(hashtag) || !hashtag.valid?
|
||||
|
@ -392,6 +392,14 @@ 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 ignore_hashtags?
|
||||
@ignore_hashtags ||= DomainBlock.reject_hashtag?(@account.domain)
|
||||
end
|
||||
|
||||
def related_to_local_activity?
|
||||
fetch? || followed_by_local_accounts? || requested_through_relay? ||
|
||||
responds_to_followed_account? || addresses_local_accounts?
|
||||
|
|
|
@ -15,7 +15,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
|||
return
|
||||
end
|
||||
|
||||
if target_account.blocking?(@account) || target_account.domain_blocking?(@account.domain) || target_account.moved? || target_account.instance_actor?
|
||||
if target_account.blocking?(@account) || target_account.domain_blocking?(@account.domain) || target_account.moved? || target_account.instance_actor? || block_new_follow?
|
||||
reject_follow_request!(target_account)
|
||||
return
|
||||
end
|
||||
|
@ -30,7 +30,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
|||
|
||||
follow_request = FollowRequest.create!(account: @account, target_account: target_account, uri: @json['id'])
|
||||
|
||||
if target_account.locked? || @account.silenced?
|
||||
if target_account.locked? || @account.silenced? || block_straight_follow?
|
||||
LocalNotificationWorker.perform_async(target_account.id, follow_request.id, 'FollowRequest', 'follow_request')
|
||||
else
|
||||
AuthorizeFollowService.new.call(@account, target_account)
|
||||
|
@ -42,4 +42,12 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
|||
json = Oj.dump(serialize_payload(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), ActivityPub::RejectFollowSerializer))
|
||||
ActivityPub::DeliveryWorker.perform_async(json, target_account.id, @account.inbox_url)
|
||||
end
|
||||
|
||||
def block_straight_follow?
|
||||
@block_straight_follow ||= DomainBlock.reject_straight_follow?(@account.domain)
|
||||
end
|
||||
|
||||
def block_new_follow?
|
||||
@block_new_follow ||= DomainBlock.reject_new_follow?(@account.domain)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ class StatusReachFinder
|
|||
if @status.reblog?
|
||||
[]
|
||||
else
|
||||
Account.where(id: reached_account_ids).inboxes
|
||||
Account.where(id: reached_account_ids).where.not(domain: banned_domains).inboxes
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ class StatusReachFinder
|
|||
elsif @status.direct_visibility? || @status.limited_visibility?
|
||||
[]
|
||||
else
|
||||
@status.account.followers.inboxes
|
||||
@status.account.followers.where.not(domain: banned_domains).inboxes
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -93,4 +93,16 @@ class StatusReachFinder
|
|||
def unsafe?
|
||||
@options[:unsafe]
|
||||
end
|
||||
|
||||
def banned_domains
|
||||
return @banned_domains if @banned_domains
|
||||
blocks = []
|
||||
blocks << DomainBlock.where(reject_send_not_public_searchability: true).pluck(:domain) if @status.compute_searchability != 'public'
|
||||
blocks << DomainBlock.where(reject_send_unlisted_dissubscribable: true).pluck(:domain) if @status.unlisted_visibility? && @status.account.dissubscribable
|
||||
blocks << DomainBlock.where(reject_send_public_unlisted: true).pluck(:domain) if @status.public_unlisted_visibility?
|
||||
blocks << DomainBlock.where(reject_send_dissubscribable: true).pluck(:domain) if @status.account.dissubscribable
|
||||
blocks << DomainBlock.where(reject_send_media: true).pluck(:domain) if @status.with_media?
|
||||
blocks << DomainBlock.where(reject_send_sensitive: true).pluck(:domain) if (@status.with_media? && @status.sensitive) || @status.spoiler_text
|
||||
return @banned_domains = blocks.uniq
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue