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.

25 lines
862 B

  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 unless reblogged_status.account.blocking?(account)
  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