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.

24 lines
660 B

  1. class FavouriteService < BaseService
  2. # Favourite a status and notify remote user
  3. # @param [Account] account
  4. # @param [Status] status
  5. # @return [Favourite]
  6. def call(account, status)
  7. favourite = Favourite.create!(account: account, status: status)
  8. account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
  9. if status.local?
  10. NotificationMailer.favourite(status, account).deliver_later
  11. else
  12. send_interaction_service.(favourite.stream_entry, status.account)
  13. end
  14. favourite
  15. end
  16. private
  17. def send_interaction_service
  18. @send_interaction_service ||= SendInteractionService.new
  19. end
  20. end