forked from fedi/mastodon
3319473b2c
It can take as much as 0.5s if not longer to complete
19 lines
559 B
Ruby
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
|