* Change: サークルの送り先アカウント指定方法を`account_username`(Fedibirdと同様)に変更 (#283) * Change: サークルの送り先アカウント指定方法を`account_username`(Fedibirdと同様)に変更 * Test: テストを追加 * Maybe Fix: Fedibirdで自分限定と認識される問題 * Fix test
This commit is contained in:
parent
203617edaf
commit
8383288219
4 changed files with 47 additions and 6 deletions
|
@ -119,10 +119,7 @@ class ActivityPub::TagManager
|
|||
end.compact
|
||||
end
|
||||
when 'limited'
|
||||
status.mentions.each_with_object([]) do |mention, result|
|
||||
result << uri_for(mention.account)
|
||||
result << followers_uri_for(mention.account) if mention.account.group?
|
||||
end.compact
|
||||
['kmyblue:Limited'] # to avoid Fedibird personal visibility
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ class StatusReachFinder
|
|||
end
|
||||
end
|
||||
|
||||
def inboxes_for_limited
|
||||
DeliveryFailureTracker.without_unavailable(
|
||||
@status.mentioned_accounts.where.not(domain: nil).pluck(:inbox_url).compact.uniq
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def reached_account_inboxes
|
||||
|
|
|
@ -7,13 +7,23 @@ class ActivityPub::DistributionWorker < ActivityPub::RawDistributionWorker
|
|||
@status = Status.find(status_id)
|
||||
@account = @status.account
|
||||
|
||||
distribute!
|
||||
if @status.limited_visibility?
|
||||
distribute_limited!
|
||||
else
|
||||
distribute!
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def distribute_limited!
|
||||
ActivityPub::DeliveryWorker.push_bulk(inboxes_for_limited, limit: 1_000) do |inbox_url|
|
||||
[payload, @account.id, inbox_url, options]
|
||||
end
|
||||
end
|
||||
|
||||
def inboxes
|
||||
@inboxes ||= status_reach_finder.inboxes
|
||||
end
|
||||
|
@ -22,6 +32,10 @@ class ActivityPub::DistributionWorker < ActivityPub::RawDistributionWorker
|
|||
@inboxes_for_misskey ||= status_reach_finder.inboxes_for_misskey
|
||||
end
|
||||
|
||||
def inboxes_for_limited
|
||||
@inboxes_for_limited ||= status_reach_finder.inboxes_for_limited
|
||||
end
|
||||
|
||||
def status_reach_finder
|
||||
@status_reach_finder ||= StatusReachFinder.new(@status)
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ describe ActivityPub::DistributionWorker do
|
|||
subject { described_class.new }
|
||||
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com', domain: 'example.com') }
|
||||
let(:follower) { Fabricate(:account, protocol: :activitypub, shared_inbox_url: 'http://example.com', inbox_url: 'http://example.com/follower/inbox', domain: 'example.com') }
|
||||
|
||||
describe '#perform' do
|
||||
before do
|
||||
|
@ -24,6 +24,17 @@ describe ActivityPub::DistributionWorker do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with unlisted status' do
|
||||
before do
|
||||
status.update(visibility: :unlisted)
|
||||
end
|
||||
|
||||
it 'delivers to followers' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]])
|
||||
subject.perform(status.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with private status' do
|
||||
before do
|
||||
status.update(visibility: :private)
|
||||
|
@ -35,6 +46,19 @@ describe ActivityPub::DistributionWorker do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with limited status' do
|
||||
before do
|
||||
status.update(visibility: :limited)
|
||||
status.capability_tokens.create!
|
||||
status.mentions.create!(account: follower, silent: true)
|
||||
end
|
||||
|
||||
it 'delivers to followers' do
|
||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com/follower/inbox', anything]])
|
||||
subject.perform(status.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with direct status' do
|
||||
let(:mentioned_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/inbox', domain: 'foo.bar') }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue