0
0
Fork 0

Stop trying to shoehorn all Salmon updates into the poor database-connected

StreamEntry model. Simply render Salmon slaps as they are needed
This commit is contained in:
Eugen Rochko 2017-02-12 00:48:53 +01:00
parent 94d2182717
commit 0518492158
22 changed files with 304 additions and 266 deletions

View file

@ -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