about summary refs log tree commit diff
path: root/app/services/favourite_service.rb
diff options
context:
space:
mode:
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