This repository has been archived on 2019-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon/app/services/favourite_service.rb
Eugen Rochko 3319473b2c Move PubSubHubbub pinging to a background worker
It can take as much as 0.5s if not longer to complete
2016-10-05 13:50:21 +02:00

19 lines
559 B
Ruby

class FavouriteService < BaseService
# Favourite a status and notify remote user
# @param [Account] account
# @param [Status] status
# @return [Favourite]
def call(account, status)
favourite = Favourite.create!(account: account, status: status)
HubPingWorker.perform_async(account.id)
if status.local?
NotificationMailer.favourite(status, account).deliver_later unless status.account.blocking?(account)
else
NotificationWorker.perform_async(favourite.stream_entry.id, status.account_id)
end
favourite
end
end