2
0

Add experimental basic quote post authoring (#35355)

This commit is contained in:
Claire
2025-07-25 14:35:24 +02:00
committed by GitHub
parent 81da377d8e
commit 5a88b7f683
25 changed files with 619 additions and 41 deletions

View File

@@ -0,0 +1,30 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ActivityPub::QuoteRequestWorker do
subject { described_class.new }
let(:quoted_account) { Fabricate(:account, inbox_url: 'http://example.com', domain: 'example.com') }
let(:quoted_status) { Fabricate(:status, account: quoted_account) }
let(:status) { Fabricate(:status, text: 'foo') }
let(:quote) { Fabricate(:quote, status: status, quoted_status: quoted_status, activity_uri: 'TODO') } # TODO: activity URI
describe '#perform' do
it 'sends the expected QuoteRequest activity' do
subject.perform(quote.id)
expect(ActivityPub::DeliveryWorker)
.to have_enqueued_sidekiq_job(match_object_shape, quote.account_id, 'http://example.com', {})
end
def match_object_shape
match_json_values(
type: 'QuoteRequest',
actor: ActivityPub::TagManager.instance.uri_for(quote.account),
object: ActivityPub::TagManager.instance.uri_for(quoted_status),
instrument: anything # TODO: inline post in request?
)
end
end
end

View File

@@ -9,36 +9,64 @@ RSpec.describe ActivityPub::StatusUpdateDistributionWorker do
let(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com', domain: 'example.com') }
describe '#perform' do
before do
follower.follow!(status.account)
status.snapshot!
status.text = 'bar'
status.edited_at = Time.now.utc
status.snapshot!
status.save!
end
context 'with public status' do
context 'with an explicitly edited status' do
before do
status.update(visibility: :public)
follower.follow!(status.account)
status.snapshot!
status.text = 'bar'
status.edited_at = Time.now.utc
status.snapshot!
status.save!
end
it 'delivers to followers' do
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), status.account.id, 'http://example.com', anything]]) do
subject.perform(status.id)
context 'with public status' do
before do
status.update(visibility: :public)
end
it 'delivers to followers' do
expect { subject.perform(status.id) }
.to enqueue_sidekiq_job(ActivityPub::DeliveryWorker).with(match_json_values(type: 'Update'), status.account_id, 'http://example.com', anything)
end
end
context 'with private status' do
before do
status.update(visibility: :private)
end
it 'delivers to followers' do
expect { subject.perform(status.id) }
.to enqueue_sidekiq_job(ActivityPub::DeliveryWorker).with(match_json_values(type: 'Update'), status.account_id, 'http://example.com', anything)
end
end
end
context 'with private status' do
context 'with an implicitly edited status' do
before do
status.update(visibility: :private)
follower.follow!(status.account)
end
it 'delivers to followers' do
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), status.account.id, 'http://example.com', anything]]) do
subject.perform(status.id)
context 'with public status' do
before do
status.update(visibility: :public)
end
it 'delivers to followers' do
expect { subject.perform(status.id, { 'updated_at' => Time.now.utc.iso8601 }) }
.to enqueue_sidekiq_job(ActivityPub::DeliveryWorker).with(match_json_values(type: 'Update'), status.account_id, 'http://example.com', anything)
end
end
context 'with private status' do
before do
status.update(visibility: :private)
end
it 'delivers to followers' do
expect { subject.perform(status.id, { 'updated_at' => Time.now.utc.iso8601 }) }
.to enqueue_sidekiq_job(ActivityPub::DeliveryWorker).with(match_json_values(type: 'Update'), status.account_id, 'http://example.com', anything)
end
end
end