mirror of
https://github.com/mastodon/mastodon.git
synced 2025-10-05 00:22:42 +00:00
Fix CW being moved to text when posting quote posts with empty text (#36151)
This commit is contained in:
parent
2664bb628b
commit
fbf093a87f
|
@ -66,7 +66,7 @@ class PostStatusService < BaseService
|
|||
|
||||
def preprocess_attributes!
|
||||
@sensitive = (@options[:sensitive].nil? ? @account.user&.setting_default_sensitive : @options[:sensitive]) || @options[:spoiler_text].present?
|
||||
@text = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present?
|
||||
@text = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present? && @quoted_status.blank?
|
||||
@visibility = @options[:visibility] || @account.user&.setting_default_privacy
|
||||
@visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced?
|
||||
@visibility = :private if @quoted_status&.private_visibility?
|
||||
|
|
|
@ -226,6 +226,29 @@ RSpec.describe '/api/v1/statuses' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with a self-quote post and a CW but no text', feature: :outgoing_quotes do
|
||||
let(:quoted_status) { Fabricate(:status, account: user.account) }
|
||||
let(:params) do
|
||||
{
|
||||
spoiler_text: 'this is a CW',
|
||||
quoted_status_id: quoted_status.id,
|
||||
}
|
||||
end
|
||||
|
||||
it 'returns a quote post, as well as rate limit headers', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:quote]).to be_present
|
||||
expect(response.parsed_body[:spoiler_text]).to eq 'this is a CW'
|
||||
expect(response.parsed_body[:content]).to eq ''
|
||||
expect(response.headers['X-RateLimit-Limit']).to eq RateLimiter::FAMILIES[:statuses][:limit].to_s
|
||||
expect(response.headers['X-RateLimit-Remaining']).to eq (RateLimiter::FAMILIES[:statuses][:limit] - 1).to_s
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a safeguard' do
|
||||
let!(:alice) { Fabricate(:account, username: 'alice') }
|
||||
let!(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
|
Loading…
Reference in New Issue
Block a user