favourite_service.rb 563 B

123456789101112131415161718
  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. NotificationWorker.perform_async(favourite.stream_entry.id, status.account_id)
  13. end
  14. favourite
  15. end
  16. end