reblog_service.rb 811 B

12345678910111213141516171819202122232425
  1. class ReblogService < BaseService
  2. # Reblog a status and notify its remote author
  3. # @param [Account] account Account to reblog from
  4. # @param [Status] reblogged_status Status to be reblogged
  5. # @return [Status]
  6. def call(account, reblogged_status)
  7. reblog = account.statuses.create!(reblog: reblogged_status, text: '')
  8. DistributionWorker.perform_async(reblog.id)
  9. account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
  10. if reblogged_status.local?
  11. NotificationMailer.reblog(reblogged_status, account).deliver_later
  12. else
  13. NotificationWorker.perform_async(reblog.stream_entry.id, reblogged_status.account_id)
  14. end
  15. reblog
  16. end
  17. private
  18. def send_interaction_service
  19. @send_interaction_service ||= SendInteractionService.new
  20. end
  21. end