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
1004 B

  1. # frozen_string_literal: true
  2. class ReblogService < BaseService
  3. # Reblog a status and notify its remote author
  4. # @param [Account] account Account to reblog from
  5. # @param [Status] reblogged_status Status to be reblogged
  6. # @return [Status]
  7. def call(account, reblogged_status)
  8. reblogged_status = reblogged_status.reblog if reblogged_status.reblog?
  9. raise Mastodon::NotPermitted if reblogged_status.private_visibility? || !reblogged_status.permitted?(account)
  10. reblog = account.statuses.create!(reblog: reblogged_status, text: '')
  11. DistributionWorker.perform_async(reblog.id)
  12. Pubsubhubbub::DistributionWorker.perform_async(reblog.stream_entry.id)
  13. if reblogged_status.local?
  14. NotifyService.new.call(reblog.reblog.account, reblog)
  15. else
  16. NotificationWorker.perform_async(reblog.stream_entry.id, reblog.reblog.account_id)
  17. end
  18. reblog
  19. end
  20. private
  21. def send_interaction_service
  22. @send_interaction_service ||= SendInteractionService.new
  23. end
  24. end