Skip to content
Snippets Groups Projects
Commit 09c042aa authored by ThibG's avatar ThibG Committed by Eugen Rochko
Browse files

Handle StaleObjectError when retrieving polls (#10208)

parent 637c952c
No related branches found
No related tags found
No related merge requests found
......@@ -32,12 +32,17 @@ class ActivityPub::FetchRemotePollService < BaseService
# votes, so we need to remove them
poll.votes.delete_all if latest_options != poll.options
poll.update!(
last_fetched_at: Time.now.utc,
expires_at: expires_at,
options: latest_options,
cached_tallies: items.map { |item| item.dig('replies', 'totalItems') || 0 }
)
begin
poll.update!(
last_fetched_at: Time.now.utc,
expires_at: expires_at,
options: latest_options,
cached_tallies: items.map { |item| item.dig('replies', 'totalItems') || 0 }
)
rescue ActiveRecord::StaleObjectError
poll.reload
retry
end
end
private
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment