From 0518492158af247f3b99a8f27f4498d1bcc91117 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 12 Feb 2017 00:48:53 +0100 Subject: Stop trying to shoehorn all Salmon updates into the poor database-connected StreamEntry model. Simply render Salmon slaps as they are needed --- app/services/favourite_service.rb | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'app/services/favourite_service.rb') 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 -- cgit