Fix: リモートアカウント情報のNgWord検査でNULLが出る問題 (#541)

* Fix: リモートアカウント情報のNgWord検査でNULLが出る問題

* Add test
This commit is contained in:
KMY(雪あすか) 2024-02-13 14:19:30 +09:00 committed by KMY
parent 5274a399d6
commit d9b9e66bb5
2 changed files with 29 additions and 2 deletions

View file

@ -132,8 +132,8 @@ class ActivityPub::ProcessAccountService < BaseService
end
def valid_account?
display_name = @json['name']
note = @json['summary']
display_name = @json['name'] || ''
note = @json['summary'] || ''
!Admin::NgWord.reject?(display_name) && !Admin::NgWord.reject?(note)
end

View file

@ -190,6 +190,33 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
end
end
context 'when account is using note contains ng words' do
subject { described_class.new.call(account.username, account.domain, payload) }
let!(:account) { Fabricate(:account, username: 'alice', domain: 'example.com') }
let(:payload) do
{
id: 'https://foo.test',
type: 'Actor',
inbox: 'https://foo.test/inbox',
name: 'Ohagi',
}.with_indifferent_access
end
it 'creates account when ng word is not set' do
Setting.ng_words = ['Amazon']
subject
expect(account.reload.display_name).to eq 'Ohagi'
end
it 'does not create account when ng word is set' do
Setting.ng_words = ['Ohagi']
subject
expect(account.reload.display_name).to_not eq 'Ohagi'
end
end
context 'when account is not suspended' do
subject { described_class.new.call('alice', 'example.com', payload) }