Add: #667 プレビューカード、参照のフェッチを行わないドメインの設定 (#690)

This commit is contained in:
KMY(雪あすか) 2024-04-03 12:37:18 +09:00 committed by GitHub
parent ff2860d0df
commit d89e1114bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 123 additions and 2 deletions

View file

@ -284,6 +284,20 @@ RSpec.describe FetchLinkCardService do
expect(status.preview_card.title).to eq 'Hello world'
end
end
context 'when URL domain is blocked by admin' do
let(:status) { Fabricate(:status, text: 'http://example.com/html') }
let(:custom_before) { true }
before do
Setting.stop_link_preview_domains = ['example.com']
end
it 'creates preview card' do
subject.call(status)
expect(status.preview_card).to be_nil
end
end
end
context 'with a remote status' do

View file

@ -175,6 +175,33 @@ RSpec.describe ProcessReferencesService, type: :service do
end
end
context 'with fetch is blocked by admin' do
let(:text) { 'Hello RT https://web.example.com/note' }
before do
Setting.stop_fetch_activity_domains = ['web.example.com']
stub_request(:get, 'https://web.example.com/note').to_return(status: 404)
end
context 'when the post is known' do
let(:target_status) { Fabricate(:status, uri: 'https://example.com/note', url: 'https://web.example.com/note') }
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'RT'
expect(notify?).to be true
end
end
context 'when the post is unknown' do
it 'post status', :sidekiq_inline do
expect(subject.size).to eq 0
expect(a_request(:get, 'https://web.example.com/note')).to_not have_been_made
end
end
end
context 'when unfetched remote post' do
let(:account) { Fabricate(:account, followers_url: 'http://example.com/followers', domain: 'example.com', uri: 'https://example.com/actor') }
let(:object_json) do