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.

32 lines
878 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']) || !announceable?(original_status)
  7. status = Status.find_by(account: @account, reblog: original_status)
  8. return status unless status.nil?
  9. status = Status.create!(
  10. account: @account,
  11. reblog: original_status,
  12. uri: @json['id'],
  13. created_at: @json['published'],
  14. override_timestamps: @options[:override_timestamps],
  15. visibility: original_status.visibility
  16. )
  17. distribute(status)
  18. status
  19. end
  20. private
  21. def announceable?(status)
  22. status.account_id == @account.id || status.public_visibility? || status.unlisted_visibility?
  23. end
  24. end