diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index f0dec6967e..08e580ea8e 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -65,6 +65,7 @@ class Form::AdminSettings enable_local_timeline emoji_reaction_disallow_domains permit_new_account_domains + hold_remote_new_accounts ).freeze INTEGER_KEYS = %i( @@ -107,6 +108,7 @@ class Form::AdminSettings stranger_mention_from_local_ng enable_local_timeline delete_content_cache_without_reaction + hold_remote_new_accounts ).freeze UPLOAD_KEYS = %i( diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 35423a54c8..632de6091d 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -140,6 +140,7 @@ class ActivityPub::ProcessAccountService < BaseService end def blocking_new_account? + return false unless Setting.hold_remote_new_accounts return false if permit_new_account_domains.blank? permit_new_account_domains.exclude?(@domain) diff --git a/app/views/admin/ng_words/show.html.haml b/app/views/admin/ng_words/show.html.haml index 5e38dcebef..9115237e86 100644 --- a/app/views/admin/ng_words/show.html.haml +++ b/app/views/admin/ng_words/show.html.haml @@ -36,6 +36,9 @@ = t 'admin.ng_words.remote_approval_hint' = link_to t('admin.ng_words.remote_approval_list'), admin_accounts_path(status: 'remote_pending', origin: 'remote') + .fields-group + = f.input :hold_remote_new_accounts, wrapper: :with_label, as: :boolean, label: t('admin.ng_words.hold_remote_new_accounts') + .fields-group = f.input :permit_new_account_domains, wrapper: :with_label, as: :text, kmyblue: true, input_html: { rows: 6 }, label: t('admin.ng_words.permit_new_account_domains') diff --git a/config/locales/en.yml b/config/locales/en.yml index 4e97f87c95..4d6b67f875 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -650,6 +650,7 @@ en: ng_words: hide_local_users_for_anonymous: Hide timeline local user posts from anonymous history_hint: We recommend that you regularly check your NG words to make sure that you have not specified the NG words incorrectly. + hold_remote_new_accounts: Hold new remote accounts keywords: Reject keywords keywords_for_stranger_mention: Reject keywords when mention/reply/reference/quote from strangers keywords_for_stranger_mention_hint: This words are checked posts from other servers only. diff --git a/config/locales/ja.yml b/config/locales/ja.yml index f2d711ae58..bf2c8b6088 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -643,6 +643,7 @@ ja: ng_words: hide_local_users_for_anonymous: ログインしていない状態でローカルユーザーの投稿をタイムラインから取得できないようにする history_hint: 設定されたNGワードによって実際に拒否された投稿などは、履歴より確認できます。NGワードの指定に誤りがないか定期的に確認することをおすすめします。 + hold_remote_new_accounts: リモートの新規アカウントを保留する keywords: 投稿できないキーワード keywords_for_stranger_mention: フォローしていないアカウントへのメンションや参照で利用できないキーワード keywords_for_stranger_mention_hint: フォローしていないアカウントへのメンション、参照、引用にのみ適用されます diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 378f9e605a..c9460f9b18 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -12,6 +12,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do describe 'about blocking new remote account' do subject { described_class.new.call('alice', 'example.com', payload) } + let(:hold_remote_new_accounts) { true } let(:permit_new_account_domains) { nil } let(:payload) do { @@ -24,6 +25,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do end before do + Setting.hold_remote_new_accounts = hold_remote_new_accounts Setting.permit_new_account_domains = permit_new_account_domains end @@ -43,6 +45,16 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do expect(subject.remote_pending).to be true end + context 'when the domain is not on list but hold_remote_new_accounts is disabled' do + let(:hold_remote_new_accounts) { false } + + it 'creates normal account' do + expect(subject).to_not be_nil + expect(subject.suspended?).to be false + expect(subject.remote_pending).to be false + end + end + context 'with has existing account' do before do Fabricate(:account, uri: 'https://foo.test', domain: 'example.com', username: 'alice', note: 'old bio')