about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-06 12:51:55 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-06 12:51:55 +0100
commitc605b828b53165cb0161a1885e03202013b63f52 (patch)
treea667e98afc79ca3eaa49f46955529f4dc5f2f101 /app/services
parentaab330eb2d39711e19753e89ba7ff67521929cf0 (diff)
Adding routes to follow, unfollow, favourite and reblog (locally known models)
Diffstat (limited to 'app/services')
-rw-r--r--app/services/favourite_service.rb19
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