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:
parent
94d2182717
commit
0518492158
22 changed files with 304 additions and 266 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue