diff options
Diffstat (limited to 'app/services/unfavourite_service.rb')
-rw-r--r-- | app/services/unfavourite_service.rb | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/app/services/unfavourite_service.rb b/app/services/unfavourite_service.rb index de6e84e7d..5f0ba4254 100644 --- a/app/services/unfavourite_service.rb +++ b/app/services/unfavourite_service.rb @@ -5,10 +5,34 @@ class UnfavouriteService < BaseService favourite = Favourite.find_by!(account: account, status: status) favourite.destroy! - unless status.local? - NotificationWorker.perform_async(favourite.stream_entry.id, status.account_id) - end + NotificationWorker.perform_async(build_xml(favourite), account.id, status.account_id) unless status.local? favourite end + + private + + def build_xml(favourite) + description = "#{favourite.account.acct} no longer favourites a status by #{favourite.status.account.acct}" + + Nokogiri::XML::Builder.new do |xml| + entry(xml, true) do + unique_id xml, Time.now.utc, favourite.id, 'Favourite' + title xml, description + content xml, description + + author(xml) do + include_author xml, favourite.account + end + + object_type xml, :activity + verb xml, :unfavorite + in_reply_to xml, TagManager.instance.uri_for(favourite.status), TagManager.instance.url_for(favourite.status) + + target(xml) do + include_target xml, favourite.status + end + end + end.to_xml + end end |