Change: #538 NGワード「フォローしていないアカウントへのメンションで利用できないキーワード」を、参照投稿にも適用する (#544)

* Change: #538 NGワード「フォローしていないアカウントへのメンションで利用できないキーワード」を、参照投稿にも適用する

* Update create.rb

* Update create.rb

* Update create.rb

* Fix test
This commit is contained in:
KMY(雪あすか) 2024-02-16 18:19:14 +09:00 committed by GitHub
parent 5c543c602b
commit 76b5d4f2c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 265 additions and 41 deletions

View file

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::FetchReferencesService, type: :service do
subject { described_class.new.call(status, payload) }
subject { described_class.new.call(status.account, payload) }
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }
let(:status) { Fabricate(:status, account: actor) }

View file

@ -29,7 +29,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
tag: json_tags,
}
end
let(:json) { Oj.load(Oj.dump(payload)) }
let(:payload_override) { {} }
let(:json) { Oj.load(Oj.dump(payload.merge(payload_override))) }
let(:alice) { Fabricate(:account) }
let(:bob) { Fabricate(:account) }
@ -601,6 +602,49 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
end
end
context 'when hit ng words for reference' do
let!(:target_status) { Fabricate(:status, account: alice) }
let(:payload_override) do
{
references: {
id: 'target_status',
type: 'Collection',
first: {
type: 'CollectionPage',
next: nil,
partOf: 'target_status',
items: [
ActivityPub::TagManager.instance.uri_for(target_status),
],
},
},
}
end
let(:content) { 'ng word test' }
it 'update status' do
Form::AdminSettings.new(ng_words_for_stranger_mention: 'test', stranger_mention_from_local_ng: '1').save
subject.call(status, json, json)
expect(status.reload.text).to_not eq content
expect(status.references.pluck(:id)).to_not include target_status.id
end
context 'when alice follows sender' do
before do
alice.follow!(status.account)
end
it 'update status' do
Form::AdminSettings.new(ng_words_for_stranger_mention: 'test').save
subject.call(status, json, json)
expect(status.reload.text).to eq content
expect(status.references.pluck(:id)).to include target_status.id
end
end
end
context 'when using hashtag under limit' do
let(:json_tags) do
[