diff options
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/favourite_service.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb new file mode 100644 index 000000000..547811e73 --- /dev/null +++ b/app/services/favourite_service.rb @@ -0,0 +1,19 @@ +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) + account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url]) + return favourite if status.local? + send_interaction_service.(favourite.stream_entry, status.account) + favourite + end + + private + + def send_interaction_service + @send_interaction_service ||= SendInteractionService.new + end +end |