mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-07 10:22:48 +00:00
Disallow making private posts quotable (#35780)
This commit is contained in:
parent
b0ce1ce49d
commit
a2cddb9eac
|
@ -10,6 +10,10 @@ module Status::InteractionPolicyConcern
|
||||||
followed: (1 << 3),
|
followed: (1 << 3),
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
included do
|
||||||
|
before_validation :downgrade_quote_policy, if: -> { local? && !distributable? }
|
||||||
|
end
|
||||||
|
|
||||||
def quote_policy_as_keys(kind)
|
def quote_policy_as_keys(kind)
|
||||||
case kind
|
case kind
|
||||||
when :automatic
|
when :automatic
|
||||||
|
@ -52,4 +56,8 @@ module Status::InteractionPolicyConcern
|
||||||
|
|
||||||
:denied
|
:denied
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def downgrade_quote_policy
|
||||||
|
self.quote_approval_policy = 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -90,5 +90,31 @@ RSpec.describe 'Interaction policies', feature: :outgoing_quotes do
|
||||||
.to_not have_enqueued_sidekiq_job
|
.to_not have_enqueued_sidekiq_job
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user