Browse Source

Do not rely on activity arriving exactly once after delete arrived (#4754)

master
Eugen Rochko 7 years ago
committed by GitHub
parent
commit
c2980d5b17
2 changed files with 7 additions and 14 deletions
  1. +1
    -8
      app/lib/activitypub/activity.rb
  2. +6
    -6
      app/lib/activitypub/activity/delete.rb

+ 1
- 8
app/lib/activitypub/activity.rb View File

@ -97,14 +97,7 @@ class ActivityPub::Activity
end
def delete_arrived_first?(uri)
key = "delete_upon_arrival:#{@account.id}:#{uri}"
if redis.exists(key)
redis.del(key)
true
else
false
end
redis.exists("delete_upon_arrival:#{@account.id}:#{uri}")
end
def delete_later!(uri)

+ 6
- 6
app/lib/activitypub/activity/delete.rb View File

@ -5,12 +5,12 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
status = Status.find_by(uri: object_uri, account: @account)
status ||= Status.find_by(uri: @object['_:atomUri'], account: @account) if @object.is_a?(Hash) && @object['_:atomUri'].present?
if status.nil?
delete_later!(object_uri)
else
forward_for_reblogs(status)
delete_now!(status)
end
delete_later!(object_uri)
return if status.nil?
forward_for_reblogs(status)
delete_now!(status)
end
private

Loading…
Cancel
Save