Likely fix #2458, fix #2031 - handle out-of-order deletes for statuses (#2734)

* Likely fix #2458, fix #2031 - handle out-of-order deletes for statuses

If a delete arrives before the original status, cache that information
for 6h, and if the original status arrives in that window, ignore it

* Add test case
This commit is contained in:
Eugen Rochko 2017-05-04 04:34:57 +02:00
parent 456478c4e1
commit 7539254e96
2 changed files with 60 additions and 1 deletions

View file

@ -40,6 +40,11 @@ class ProcessFeedService < BaseService
private
def create_status
if redis.exists("delete_upon_arrival:#{id}")
Rails.logger.debug "Delete for status #{id} was queued, ignoring"
return
end
Rails.logger.debug "Creating remote status #{id}"
status, just_created = status_from_xml(@xml)
@ -82,7 +87,13 @@ class ProcessFeedService < BaseService
def delete_status
Rails.logger.debug "Deleting remote status #{id}"
status = Status.find_by(uri: id)
RemoveStatusService.new.call(status) unless status.nil?
if status.nil?
redis.setex("delete_upon_arrival:#{id}", 6 * 3_600, id)
else
RemoveStatusService.new.call(status)
end
nil
end
@ -283,5 +294,9 @@ class ProcessFeedService < BaseService
"#{username}@#{domain}"
end
def redis
Redis.current
end
end
end