Add: プロキシアカウントを動的に識別する簡易的な仕組み

This commit is contained in:
KMY 2023-10-07 13:07:35 +09:00
parent 22d03b06da
commit 41c1aaf54d
3 changed files with 72 additions and 2 deletions

View file

@ -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? || block_straight_follow? || (@account.bot? && target_account.user&.setting_lock_follow_from_bot)
if target_account.locked? || @account.silenced? || block_straight_follow? || ((@account.bot? || proxy_account?) && target_account.user&.setting_lock_follow_from_bot)
LocalNotificationWorker.perform_async(target_account.id, follow_request.id, 'FollowRequest', 'follow_request')
else
AuthorizeFollowService.new.call(@account, target_account)
@ -50,4 +50,24 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
def block_new_follow?
@block_new_follow ||= DomainBlock.reject_new_follow?(@account.domain)
end
def proxy_account?
(@account.username.downcase.include?('proxy') ||
@account.username.downcase.include?('followbot') ||
@account.display_name&.downcase&.include?('proxy') ||
@account.display_name&.include?('プロキシ') ||
@account.note&.downcase&.include?('proxy') ||
@account.note&.include?('プロキシ')) && proxyable_software?
end
def proxyable_software?
info = instance_info
return false if info.nil?
%w(misskey calckey firefish meisskey cherrypick).include?(info.software)
end
def instance_info
@instance_info ||= InstanceInfo.find_by(domain: @account.domain)
end
end