Fix `/api/v1/statuses/:id/context` sometimes returing `Mastodon-Async-Refresh` without `result_count` (#36779)

pull/36864/head
Claire 2 weeks ago
parent fbe05d42fb
commit ea663cf7c7

@ -66,7 +66,7 @@ class Api::V1::StatusesController < Api::BaseController
if async_refresh.running?
add_async_refresh_header(async_refresh)
elsif !current_account.nil? && @status.should_fetch_replies?
add_async_refresh_header(AsyncRefresh.create(refresh_key))
add_async_refresh_header(AsyncRefresh.create(refresh_key, count_results: true))
WorkerBatch.new.within do |batch|
batch.connect(refresh_key, threshold: 1.0)

@ -133,6 +133,21 @@ RSpec.describe '/api/v1/statuses' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.headers['Mastodon-Async-Refresh']).to be_nil
end
context 'with a remote status' do
let(:status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com'), created_at: 1.hour.ago, updated_at: 1.hour.ago) }
it 'returns http success and queues discovery of new posts' do
expect { get "/api/v1/statuses/#{status.id}/context", headers: headers }
.to enqueue_sidekiq_job(ActivityPub::FetchAllRepliesWorker)
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.headers['Mastodon-Async-Refresh']).to match(/result_count=0/)
end
end
end

Loading…
Cancel
Save