From 645034800d9e383da68fb10a4747801e6964360d Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Mon, 6 Jun 2016 17:19:07 +0200 Subject: [PATCH] deliver public posts to relay --- config/defaults.yml | 2 +- config/diaspora.yml.example | 4 ++-- lib/diaspora/federation/dispatcher/public.rb | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config/defaults.yml b/config/defaults.yml index b60a9e20b..f1e78f786 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -187,7 +187,7 @@ defaults: relay: outbound: send: false - handle: 'relay@relay.iliketoast.net' + url: 'https://relay.iliketoast.net/receive/public' inbound: subscribe: false scope: tags diff --git a/config/diaspora.yml.example b/config/diaspora.yml.example index 48769ed30..5bf13e07d 100644 --- a/config/diaspora.yml.example +++ b/config/diaspora.yml.example @@ -645,8 +645,8 @@ configuration: ## Section outbound: ## Section ## Enable this setting to send out public posts from this pod to a relay #send: false - ## Change default remote relay handle used for sending out here - #handle: 'relay@relay.iliketoast.net' + ## Change default remote relay url used for sending out here + #url: 'https://relay.iliketoast.net/receive/public' inbound: ## Section ## Enable this to receive public posts from relays diff --git a/lib/diaspora/federation/dispatcher/public.rb b/lib/diaspora/federation/dispatcher/public.rb index 82946e94e..399ae8488 100644 --- a/lib/diaspora/federation/dispatcher/public.rb +++ b/lib/diaspora/federation/dispatcher/public.rb @@ -4,13 +4,14 @@ module Diaspora class Public < Dispatcher def deliver_to_services deliver_to_hub if object.instance_of?(StatusMessage) - # TODO: pubsubhubbub, relay super end def deliver_to_remote(people) + targets = target_urls(people) + additional_target_urls + entity = Entities.build(object) - Workers::SendPublic.perform_async(sender.id, entity.to_s, target_urls(people), salmon_xml(entity)) + Workers::SendPublic.perform_async(sender.id, entity.to_s, targets, salmon_xml(entity)) end private @@ -19,6 +20,11 @@ module Diaspora Pod.where(id: people.map(&:pod_id).uniq).map {|pod| pod.url_to("/receive/public") } end + def additional_target_urls + return [] unless AppConfig.relay.outbound.send? && object.instance_of?(StatusMessage) + [AppConfig.relay.outbound.url] + end + def salmon_xml(entity) DiasporaFederation::Salmon::Slap.generate_xml( sender.diaspora_handle,