闭社主体 forked from https://github.com/tootsuite/mastodon
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.

29 lines
920 B

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