Add: #573 新規のアカウント認識を全て停止するオプション (#583)

This commit is contained in:
KMY(雪あすか) 2024-02-17 16:48:13 +09:00 committed by GitHub
parent 28b15ab268
commit 0048a8368e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 74 additions and 1 deletions

View file

@ -13,7 +13,7 @@ class ActivityPub::ProcessAccountService < BaseService
# Should be called with confirmed valid JSON
# and WebFinger-resolved username and domain
def call(username, domain, json, options = {})
def call(username, domain, json, options = {}) # rubocop:disable Metrics/PerceivedComplexity
return if json['inbox'].blank? || unsupported_uri_scheme?(json['id']) || domain_not_allowed?(domain)
@options = options
@ -37,6 +37,8 @@ class ActivityPub::ProcessAccountService < BaseService
@suspension_changed = false
if @account.nil?
return nil if blocking_new_account?(@domain)
with_redis do |redis|
return nil if redis.pfcount("unique_subdomains_for:#{PublicSuffix.domain(@domain, ignore_private: true)}") >= SUBDOMAINS_RATELIMIT
@ -130,6 +132,16 @@ class ActivityPub::ProcessAccountService < BaseService
@account.memorial = @json['memorial'] || false
end
def blocking_new_account?(domain)
return false if permit_new_account_domains.blank?
permit_new_account_domains.exclude?(domain)
end
def permit_new_account_domains
(Setting.permit_new_account_domains || []).compact_blank
end
def valid_account?
display_name = @json['name'] || ''
note = @json['summary'] || ''