Add: Webでの引用表示 (#50)

* Add compacted component

* 引用表示の間にコンテナをはさみ、不要なコードを削除

* 引用APIを作成、ついでにブロック状況を引用APIに反映

* テスト修正など

* 引用をキャッシュに登録

* `quote_id`が`quote_of_id`になったのをSerializerに反映

* Fix test

* 引用をフィルターの対象に含める設定+エラー修正

* ストリーミングの存在しないプロパティ削除によるエラーを修正

* Fix lint

* 他のサーバーから来た引用付き投稿を処理

* Fix test

* フィルター設定時エラーの調整

* 画像つき投稿のスタイルを調整

* 画像つき投稿の最大高さを調整

* 引用禁止・非表示の設定を追加

* ブロック対応

* マイグレーションコード調整

* 引用設定の翻訳を作成

* Lint修正

* 参照1つの場合は引用に変換する設定を削除

* 不要になったテストを削除

* ブロック設定追加、バグ修正

* 他サーバーへ引用送信・受け入れ
This commit is contained in:
KMY(雪あすか) 2023-10-02 11:12:51 +09:00 committed by GitHub
parent 3c649aa74d
commit 44b739a39a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 1362 additions and 120 deletions

View file

@ -10,6 +10,7 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:status) { Fabricate(:status, account: account, text: text, visibility: visibility) }
let(:target_status) { Fabricate(:status, account: Fabricate(:user).account, visibility: target_status_visibility) }
let(:target_status_uri) { ActivityPub::TagManager.instance.uri_for(target_status) }
let(:quote_urls) { nil }
def notify?(target_status_id = nil)
target_status_id ||= target_status.id
@ -18,7 +19,7 @@ RSpec.describe ProcessReferencesService, type: :service do
describe 'posting new status' do
subject do
described_class.new.call(status, reference_parameters, urls: urls, fetch_remote: fetch_remote)
described_class.new.call(status, reference_parameters, urls: urls, fetch_remote: fetch_remote, quote_urls: quote_urls)
status.reference_objects.pluck(:target_status_id, :attribute_type)
end
@ -35,6 +36,10 @@ RSpec.describe ProcessReferencesService, type: :service do
expect(subject.pluck(1)).to include 'RT'
expect(notify?).to be true
end
it 'not quote' do
expect(status.quote).to be_nil
end
end
context 'when multiple references' do
@ -86,6 +91,48 @@ RSpec.describe ProcessReferencesService, type: :service do
end
end
context 'with quote as parameter only' do
let(:text) { 'Hello' }
let(:quote_urls) { [ActivityPub::TagManager.instance.uri_for(target_status)] }
it 'post status' do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
end
end
context 'with quote as parameter and embed' do
let(:text) { "Hello QT #{target_status_uri}" }
let(:quote_urls) { [ActivityPub::TagManager.instance.uri_for(target_status)] }
it 'post status' do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
end
end
context 'with quote as parameter but embed is not quote' do
let(:text) { "Hello RE #{target_status_uri}" }
let(:quote_urls) { [ActivityPub::TagManager.instance.uri_for(target_status)] }
it 'post status' do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
end
end
context 'with quote and reference' do
let(:target_status2) { Fabricate(:status) }
let(:target_status2_uri) { ActivityPub::TagManager.instance.uri_for(target_status2) }
@ -240,6 +287,17 @@ RSpec.describe ProcessReferencesService, type: :service do
end
end
context 'when remove quote' do
let(:text) { "QT #{target_status_uri}" }
let(:new_text) { 'Hello' }
it 'post status' do
expect(subject.size).to eq 0
expect(status.quote).to be_nil
expect(notify?).to be false
end
end
context 'when change reference' do
let(:text) { "BT #{target_status_uri}" }
let(:new_text) { "BT #{target_status2_uri}" }
@ -250,5 +308,43 @@ RSpec.describe ProcessReferencesService, type: :service do
expect(notify?(target_status2.id)).to be true
end
end
context 'when change quote' do
let(:text) { "QT #{target_status_uri}" }
let(:new_text) { "QT #{target_status2_uri}" }
it 'post status' do
expect(subject.size).to eq 1
expect(subject).to include target_status2.id
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status2.id
expect(notify?(target_status2.id)).to be true
end
end
context 'when change quote to reference', pending: 'Will fix later' do
let(:text) { "QT #{target_status_uri}" }
let(:new_text) { "RT #{target_status_uri}" }
it 'post status' do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
expect(status.quote).to be_nil
expect(notify?(target_status.id)).to be true
end
end
context 'when change reference to quote', pending: 'Will fix later' do
let(:text) { "RT #{target_status_uri}" }
let(:new_text) { "QT #{target_status_uri}" }
it 'post status' do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
expect(notify?(target_status.id)).to be true
end
end
end
end