From c605b828b53165cb0161a1885e03202013b63f52 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 6 Mar 2016 12:51:55 +0100 Subject: Adding routes to follow, unfollow, favourite and reblog (locally known models) --- app/services/favourite_service.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/services/favourite_service.rb (limited to 'app/services/favourite_service.rb') 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 -- cgit