Skip to content

Commit

Permalink
Change: ホワイトリスト全体を有効にするオプション
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Feb 18, 2024
1 parent 1b3c0e3 commit 100557b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/form/admin_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions app/services/activitypub/process_account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def set_immediate_attributes!
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)
Expand Down
3 changes: 3 additions & 0 deletions app/views/admin/ng_words/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: フォローしていないアカウントへのメンション、参照、引用にのみ適用されます
Expand Down
12 changes: 12 additions & 0 deletions spec/services/activitypub/process_account_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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
{
Expand All @@ -24,6 +25,7 @@
end

before do
Setting.hold_remote_new_accounts = hold_remote_new_accounts
Setting.permit_new_account_domains = permit_new_account_domains
end

Expand All @@ -43,6 +45,16 @@
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')
Expand Down

0 comments on commit 100557b

Please sign in to comment.