Fix Idempotency-Key ignored when scheduling a post (#30084)
This commit is contained in:
parent
e845594878
commit
91ca90e25b
2 changed files with 9 additions and 2 deletions
|
@ -160,7 +160,7 @@ class PostStatusService < BaseService
|
||||||
|
|
||||||
def idempotency_duplicate
|
def idempotency_duplicate
|
||||||
if scheduled?
|
if scheduled?
|
||||||
@account.schedule_statuses.find(@idempotency_duplicate)
|
@account.scheduled_statuses.find(@idempotency_duplicate)
|
||||||
else
|
else
|
||||||
@account.statuses.find(@idempotency_duplicate)
|
@account.statuses.find(@idempotency_duplicate)
|
||||||
end
|
end
|
||||||
|
@ -211,7 +211,7 @@ class PostStatusService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def scheduled_options
|
def scheduled_options
|
||||||
@options.tap do |options_hash|
|
@options.dup.tap do |options_hash|
|
||||||
options_hash[:in_reply_to_id] = options_hash.delete(:thread)&.id
|
options_hash[:in_reply_to_id] = options_hash.delete(:thread)&.id
|
||||||
options_hash[:application_id] = options_hash.delete(:application)&.id
|
options_hash[:application_id] = options_hash.delete(:application)&.id
|
||||||
options_hash[:scheduled_at] = nil
|
options_hash[:scheduled_at] = nil
|
||||||
|
|
|
@ -54,6 +54,13 @@ RSpec.describe PostStatusService do
|
||||||
.to not_change { account.statuses_count }
|
.to not_change { account.statuses_count }
|
||||||
.and(not_change { previous_status.replies_count })
|
.and(not_change { previous_status.replies_count })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns existing status when used twice with idempotency key' do
|
||||||
|
account = Fabricate(:account)
|
||||||
|
status1 = subject.call(account, text: 'test', idempotency: 'meepmeep', scheduled_at: future)
|
||||||
|
status2 = subject.call(account, text: 'test', idempotency: 'meepmeep', scheduled_at: future)
|
||||||
|
expect(status2.id).to eq status1.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates response to the original status of boost' do
|
it 'creates response to the original status of boost' do
|
||||||
|
|
Loading…
Reference in a new issue