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.

24 lines
677 B

  1. # frozen_string_literal: true
  2. class ActivityPub::Activity::Announce < ActivityPub::Activity
  3. def perform
  4. original_status = status_from_uri(object_uri)
  5. original_status ||= fetch_remote_original_status
  6. return if original_status.nil? || delete_arrived_first?(@json['id'])
  7. status = Status.create!(account: @account, reblog: original_status, uri: @json['id'])
  8. distribute(status)
  9. status
  10. end
  11. private
  12. def fetch_remote_original_status
  13. if object_uri.start_with?('http')
  14. ActivityPub::FetchRemoteStatusService.new.call(object_uri)
  15. elsif @object['url'].present?
  16. ::FetchRemoteStatusService.new.call(@object['url'])
  17. end
  18. end
  19. end