You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
859 B

  1. # frozen_string_literal: true
  2. class ActivityPub::Activity::Delete < ActivityPub::Activity
  3. def perform
  4. status = Status.find_by(uri: object_uri, account: @account)
  5. status ||= Status.find_by(uri: @object['_:atomUri'], account: @account) if @object.is_a?(Hash) && @object['_:atomUri'].present?
  6. if status.nil?
  7. delete_later!(object_uri)
  8. else
  9. forward_for_reblogs(status)
  10. delete_now!(status)
  11. end
  12. end
  13. private
  14. def forward_for_reblogs(status)
  15. return if @json['signature'].blank?
  16. ActivityPub::RawDistributionWorker.push_bulk(status.reblogs.includes(:account).references(:account).merge(Account.local).pluck(:account_id)) do |account_id|
  17. [payload, account_id]
  18. end
  19. end
  20. def delete_now!(status)
  21. RemoveStatusService.new.call(status)
  22. end
  23. def payload
  24. @payload ||= Oj.dump(@json)
  25. end
  26. end