Disallow making private posts quotable (#35780)

This commit is contained in:
Claire 2025-08-14 15:58:25 +02:00 committed by GitHub
parent b0ce1ce49d
commit a2cddb9eac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 0 deletions

View File

@ -10,6 +10,10 @@ module Status::InteractionPolicyConcern
followed: (1 << 3),
}.freeze
included do
before_validation :downgrade_quote_policy, if: -> { local? && !distributable? }
end
def quote_policy_as_keys(kind)
case kind
when :automatic
@ -52,4 +56,8 @@ module Status::InteractionPolicyConcern
:denied
end
def downgrade_quote_policy
self.quote_approval_policy = 0
end
end

View File

@ -90,5 +90,31 @@ RSpec.describe 'Interaction policies', feature: :outgoing_quotes do
.to_not have_enqueued_sidekiq_job
end
end
context 'when trying to change the interaction policy of a private post' do
let(:status) { Fabricate(:status, account: user.account, visibility: :private) }
let(:params) { { quote_approval_policy: 'public' } }
it 'keeps the interaction policy, returns the status, and does not schedule distribution jobs' do
expect { subject }
.to_not(change { status.reload.quote_approval_policy }.from(0))
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body).to include(
'quote_approval' => match(
'automatic' => [],
'manual' => [],
'current_user' => 'automatic'
)
)
expect(DistributionWorker)
.to_not have_enqueued_sidekiq_job
expect(ActivityPub::StatusUpdateDistributionWorker)
.to_not have_enqueued_sidekiq_job
end
end
end
end