Change: 単方向の承認だけでフレンドサーバーが有効になるようにする (#74)

* Test: テストを先に作成

* Fix: テスト不備

* Wip: フレンドサーバーのテストを修正

* Wip: エラーを修正

* 項目のラベリングを修正

* 新しい設定が変更できないのを修正

* Wip: 削除時の処理を修正

* フレンド自動承認設定を削除

* Fix: 申請を受けたドメインのINBOXが空になる問題

* Change: #75 フレンドでないサーバーからのローカル公開を未収載に変換 (#77)
This commit is contained in:
KMY(雪あすか) 2023-10-10 21:46:26 +09:00 committed by GitHub
parent 521932c802
commit 1eb2d78b5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 314 additions and 126 deletions

View file

@ -99,7 +99,7 @@ describe StatusReachFinder do
let(:sender_software) { 'misskey' }
let(:searchability) { :public }
before { Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', available: true, active_state: :accepted, passive_state: :accepted, pseudo_relay: true) }
before { Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', available: true, active_state: :accepted, pseudo_relay: true) }
it 'send status without friend server' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
@ -114,7 +114,7 @@ describe StatusReachFinder do
context 'with follower' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted)
bob.follow!(alice)
end
@ -124,9 +124,21 @@ describe StatusReachFinder do
end
end
context 'with non-follower' do
context 'with follower but not local-distributable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, delivery_local: false)
bob.follow!(alice)
end
it 'send status' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
expect(subject.inboxes_for_friend).to_not include 'https://foo.bar/inbox'
end
end
context 'with non-follower and non-relay' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted)
end
it 'send status' do
@ -137,7 +149,7 @@ describe StatusReachFinder do
context 'with pending' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :pending)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :pending)
bob.follow!(alice)
end
@ -147,21 +159,21 @@ describe StatusReachFinder do
end
end
context 'with idle' do
context 'with unidirection from them' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :idle, passive_state: :accepted)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :idle, passive_state: :accepted)
bob.follow!(alice)
end
it 'send status' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
expect(subject.inboxes_for_friend).to_not include 'https://foo.bar/inbox'
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
expect(subject.inboxes_for_friend).to include 'https://foo.bar/inbox'
end
end
context 'when unavailable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted, available: false)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, available: false)
bob.follow!(alice)
end
@ -173,7 +185,18 @@ describe StatusReachFinder do
context 'when distributable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted, passive_state: :accepted, pseudo_relay: true)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true)
end
it 'send status' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
expect(subject.inboxes_for_friend).to include 'https://foo.bar/inbox'
end
end
context 'when distributable and following' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true)
bob.follow!(alice)
end
@ -183,9 +206,9 @@ describe StatusReachFinder do
end
end
context 'when distributable and not following' do
context 'when distributable reverse' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, pseudo_relay: true)
end
it 'send status' do
@ -193,10 +216,35 @@ describe StatusReachFinder do
expect(subject.inboxes_for_friend).to include 'https://foo.bar/inbox'
end
end
context 'when distributable but not local distributable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true, delivery_local: false)
end
it 'send status' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
expect(subject.inboxes_for_friend).to_not include 'https://foo.bar/inbox'
end
end
context 'when distributable and following but not local distributable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', passive_state: :accepted, pseudo_relay: true, delivery_local: false)
bob.follow!(alice)
end
it 'send status' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
expect(subject.inboxes_for_friend).to_not include 'https://foo.bar/inbox'
end
end
end
context 'when it contains distributable friend server' do
before { Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', available: true, active_state: :accepted, passive_state: :accepted, pseudo_relay: true) }
before do
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true)
end
it 'includes the inbox of the mentioned account' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
@ -381,9 +429,11 @@ describe StatusReachFinder do
Fabricate(:friend_domain, domain: 'def.com', inbox_url: 'https://def.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true, available: true)
Fabricate(:friend_domain, domain: 'ghi.com', inbox_url: 'https://ghi.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true, available: false)
Fabricate(:friend_domain, domain: 'jkl.com', inbox_url: 'https://jkl.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: false, available: true)
Fabricate(:friend_domain, domain: 'mno.com', inbox_url: 'https://mno.com/inbox', active_state: :accepted, passive_state: :pending, pseudo_relay: true, available: true)
Fabricate(:friend_domain, domain: 'mno.com', inbox_url: 'https://mno.com/inbox', active_state: :accepted, passive_state: :idle, pseudo_relay: true, available: true)
Fabricate(:friend_domain, domain: 'pqr.com', inbox_url: 'https://pqr.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true, available: true)
Fabricate(:unavailable_domain, domain: 'pqr.com')
Fabricate(:friend_domain, domain: 'stu.com', inbox_url: 'https://stu.com/inbox', active_state: :idle, passive_state: :accepted, pseudo_relay: true, available: true)
Fabricate(:friend_domain, domain: 'vwx.com', inbox_url: 'https://vwx.com/inbox', active_state: :idle, passive_state: :accepted, pseudo_relay: true, available: true, delivery_local: false)
end
it 'returns friend servers' do
@ -399,8 +449,13 @@ describe StatusReachFinder do
expect(subject).to_not include 'https://jkl.com/inbox'
end
it 'not contains no-mutual friends' do
expect(subject).to_not include 'https://mno.com/inbox'
it 'contains no-mutual friends' do
expect(subject).to include 'https://mno.com/inbox'
expect(subject).to include 'https://stu.com/inbox'
end
it 'not contains un local distable' do
expect(subject).to_not include 'https://vwx.com/inbox'
end
it 'not contains unavailable domain friends' do