mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
3319473b2c
It can take as much as 0.5s if not longer to complete
18 lines
559 B
Ruby
18 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
|