* Add compacted component * 引用表示の間にコンテナをはさみ、不要なコードを削除 * 引用APIを作成、ついでにブロック状況を引用APIに反映 * テスト修正など * 引用をキャッシュに登録 * `quote_id`が`quote_of_id`になったのをSerializerに反映 * Fix test * 引用をフィルターの対象に含める設定+エラー修正 * ストリーミングの存在しないプロパティ削除によるエラーを修正 * Fix lint * 他のサーバーから来た引用付き投稿を処理 * Fix test * フィルター設定時エラーの調整 * 画像つき投稿のスタイルを調整 * 画像つき投稿の最大高さを調整 * 引用禁止・非表示の設定を追加 * ブロック対応 * マイグレーションコード調整 * 引用設定の翻訳を作成 * Lint修正 * 参照1つの場合は引用に変換する設定を削除 * 不要になったテストを削除 * ブロック設定追加、バグ修正 * 他サーバーへ引用送信・受け入れ
242 lines
9 KiB
Ruby
242 lines
9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe StatusReachFinder do
|
|
describe '#inboxes' do
|
|
context 'with a local status' do
|
|
subject { described_class.new(status) }
|
|
|
|
let(:parent_status) { nil }
|
|
let(:quoted_status) { nil }
|
|
let(:visibility) { :public }
|
|
let(:searchability) { :public }
|
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
|
let(:status) { Fabricate(:status, account: alice, thread: parent_status, quote_of_id: quoted_status&.id, visibility: visibility, searchability: searchability) }
|
|
|
|
context 'with a simple case' do
|
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
|
|
|
context 'with follower' do
|
|
before do
|
|
bob.follow!(alice)
|
|
end
|
|
|
|
it 'send status' do
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
|
|
context 'with non-follower' do
|
|
it 'send status' do
|
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when misskey case with unlisted post' do
|
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
|
let(:sender_software) { 'mastodon' }
|
|
let(:visibility) { :unlisted }
|
|
|
|
before do
|
|
Fabricate(:instance_info, domain: 'foo.bar', software: sender_software)
|
|
bob.follow!(alice)
|
|
end
|
|
|
|
context 'when mastodon' do
|
|
it 'send status' do
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
expect(subject.inboxes_for_misskey).to_not include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
|
|
context 'when misskey with private searchability' do
|
|
let(:sender_software) { 'misskey' }
|
|
let(:searchability) { :private }
|
|
|
|
it 'send status without setting' do
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
expect(subject.inboxes_for_misskey).to_not include 'https://foo.bar/inbox'
|
|
end
|
|
|
|
it 'send status with setting' do
|
|
alice.user.settings.update(reject_unlisted_subscription: 'true')
|
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
|
expect(subject.inboxes_for_misskey).to include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
|
|
context 'when misskey with public searchability' do
|
|
let(:sender_software) { 'misskey' }
|
|
|
|
it 'send status with setting' do
|
|
alice.user.settings.update(reject_unlisted_subscription: 'true')
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
expect(subject.inboxes_for_misskey).to_not include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when it contains mentions of remote accounts' do
|
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
|
|
|
before do
|
|
status.mentions.create!(account: bob)
|
|
end
|
|
|
|
it 'includes the inbox of the mentioned account' do
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
|
|
context 'when it has been reblogged by a remote account' do
|
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
|
|
|
before do
|
|
bob.statuses.create!(reblog: status)
|
|
end
|
|
|
|
it 'includes the inbox of the reblogger' do
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
end
|
|
|
|
context 'when status is not public' do
|
|
let(:visibility) { :private }
|
|
|
|
it 'does not include the inbox of the reblogger' do
|
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when it has been favourited by a remote account' do
|
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
|
|
|
before do
|
|
bob.favourites.create!(status: status)
|
|
end
|
|
|
|
it 'includes the inbox of the favouriter' do
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
end
|
|
|
|
context 'when status is not public' do
|
|
let(:visibility) { :private }
|
|
|
|
it 'does not include the inbox of the favouriter' do
|
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when it has been replied to by a remote account' do
|
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
|
|
|
before do
|
|
bob.statuses.create!(thread: status, text: 'Hoge')
|
|
end
|
|
|
|
it 'includes the inbox of the replier' do
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
end
|
|
|
|
context 'when status is not public' do
|
|
let(:visibility) { :private }
|
|
|
|
it 'does not include the inbox of the replier' do
|
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when it is a reply to a remote account' do
|
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
|
let(:parent_status) { Fabricate(:status, account: bob) }
|
|
|
|
it 'includes the inbox of the replied-to account' do
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
end
|
|
|
|
context 'when status is not public and replied-to account is not mentioned' do
|
|
let(:visibility) { :private }
|
|
|
|
it 'does not include the inbox of the replied-to account' do
|
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when it is a quote to a remote account' do
|
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
|
|
let(:quoted_status) { Fabricate(:status, account: bob) }
|
|
|
|
it 'includes the inbox of the quoted-to account' do
|
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'with extended domain block' do
|
|
subject do
|
|
described_class.new(status)
|
|
end
|
|
|
|
before do
|
|
bob.follow!(alice)
|
|
tom.follow!(alice)
|
|
Fabricate(:domain_block, domain: 'example.com', severity: 'noop', **properties)
|
|
end
|
|
|
|
let(:properties) { {} }
|
|
let(:visibility) { :public }
|
|
let(:searchability) { :public }
|
|
let(:dissubscribable) { false }
|
|
let(:spoiler_text) { '' }
|
|
let(:status) { Fabricate(:status, account: alice, visibility: visibility, searchability: searchability, spoiler_text: spoiler_text) }
|
|
let(:alice) { Fabricate(:account, username: 'alice', dissubscribable: dissubscribable) }
|
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, uri: 'https://example.com/', inbox_url: 'https://example.com/inbox') }
|
|
let(:tom) { Fabricate(:account, username: 'tom', domain: 'tom.com', protocol: :activitypub, uri: 'https://tom.com/', inbox_url: 'https://tom.com/inbox') }
|
|
|
|
context 'when reject_send_not_public_searchability' do
|
|
let(:properties) { { reject_send_not_public_searchability: true } }
|
|
let(:searchability) { :private }
|
|
|
|
it 'does not include the inbox of blocked domain' do
|
|
expect(subject.inboxes).to_not include 'https://example.com/inbox'
|
|
expect(subject.inboxes).to include 'https://tom.com/inbox'
|
|
end
|
|
end
|
|
|
|
context 'when reject_send_public_unlisted' do
|
|
let(:properties) { { reject_send_public_unlisted: true } }
|
|
let(:visibility) { :public_unlisted }
|
|
|
|
it 'does not include the inbox of blocked domain' do
|
|
expect(subject.inboxes).to_not include 'https://example.com/inbox'
|
|
expect(subject.inboxes).to include 'https://tom.com/inbox'
|
|
end
|
|
|
|
context 'when reject_send_dissubscribable' do
|
|
let(:properties) { { reject_send_dissubscribable: true } }
|
|
let(:dissubscribable) { true }
|
|
|
|
it 'does not include the inbox of blocked domain' do
|
|
expect(subject.inboxes).to_not include 'https://example.com/inbox'
|
|
expect(subject.inboxes).to include 'https://tom.com/inbox'
|
|
end
|
|
end
|
|
|
|
context 'when reject_send_sensitive' do
|
|
let(:properties) { { reject_send_sensitive: true } }
|
|
let(:spoiler_text) { 'CW' }
|
|
|
|
it 'does not include the inbox of blocked domain' do
|
|
expect(subject.inboxes).to_not include 'https://example.com/inbox'
|
|
expect(subject.inboxes).to include 'https://tom.com/inbox'
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|