diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-04 04:34:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-04 04:34:57 +0200 |
commit | 13c16b4e95c134d883b54e796e842c7f72cbbe21 (patch) | |
tree | c1d18ff304b4d50ca6bfcbaa9ac9cf4e35322928 /app/services | |
parent | 4fcc0d5ac9e734deeadf305d3fc4b9c6b41b0a84 (diff) |
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
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/process_feed_service.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index 4d23a6262..70c05c938 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -42,6 +42,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) @@ -84,7 +89,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 @@ -273,5 +284,9 @@ class ProcessFeedService < BaseService def account?(xml = @xml) !xml.at_xpath('./xmlns:author', xmlns: TagManager::XMLNS).nil? end + + def redis + Redis.current + end end end |