about summary refs log tree commit diff
path: root/app/services/favourite_service.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-02-12 00:48:53 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-02-12 01:19:14 +0100
commit0518492158af247f3b99a8f27f4498d1bcc91117 (patch)
tree4e82d1e73bd9a8ac1096d788b684283c8f8c93dd /app/services/favourite_service.rb
parent94d21827174c52a6b70ba2e45f098223f5d904fa (diff)
Stop trying to shoehorn all Salmon updates into the poor database-connected
StreamEntry model. Simply render Salmon slaps as they are needed
Diffstat (limited to 'app/services/favourite_service.rb')
-rw-r--r--app/services/favourite_service.rb31
1 files changed, 26 insertions, 5 deletions
diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb
index ce1722b77..11585250f 100644
--- a/app/services/favourite_service.rb
+++ b/app/services/favourite_service.rb
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class FavouriteService < BaseService
-  include StreamEntryRenderer
-
   # Favourite a status and notify remote user
   # @param [Account] account
   # @param [Status] status
@@ -12,14 +10,37 @@ class FavouriteService < BaseService
 
     favourite = Favourite.create!(account: account, status: status)
 
-    Pubsubhubbub::DistributionWorker.perform_async(favourite.stream_entry.id)
-
     if status.local?
       NotifyService.new.call(favourite.status.account, favourite)
     else
-      NotificationWorker.perform_async(stream_entry_to_xml(favourite.stream_entry), account.id, status.account_id)
+      NotificationWorker.perform_async(build_xml(favourite), account.id, status.account_id)
     end
 
     favourite
   end
+
+  private
+
+  def build_xml(favourite)
+    Nokogiri::XML::Builder.new do |xml|
+      entry(xml, true) do
+        title xml, "#{favourite.account.acct} favourited a status by #{favourite.status.account.acct}"
+
+        author(xml) do
+          include_author xml, favourite.account
+        end
+
+        object_type xml, :activity
+        verb xml, :favourite
+
+        target(xml) do
+          author(xml) do
+            include_author xml, favourite.status.account
+          end
+
+          include_entry xml, favourite.status.stream_entry
+        end
+      end
+    end.to_xml
+  end
 end