added sync pubsubhubbub publisher client. we now should not longer require eventmachine, (in the server process, the websocket still requires it). this should also be in a job

This commit is contained in:
maxwell 2011-01-05 18:52:24 -08:00
parent 8b3a193156
commit 27d8cc8003
3 changed files with 25 additions and 1 deletions

View file

@ -1,3 +1,8 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module Jobs module Jobs
class HttpPost class HttpPost
extend ResqueJobLogging extend ResqueJobLogging

View file

@ -45,7 +45,7 @@ class Postzord::Dispatch
def deliver_to_hub def deliver_to_hub
Rails.logger.debug("event=post_to_service type=pubsub sender_handle=#{@sender.diaspora_handle}") Rails.logger.debug("event=post_to_service type=pubsub sender_handle=#{@sender.diaspora_handle}")
EventMachine::PubSubHubbub.new(AppConfig[:pubsub_server]).publish(@sender.public_url) PubSubHubbub.new(AppConfig[:pubsub_server]).publish(@sender.public_url)
end end
def deliver_to_services(url) def deliver_to_services(url)

19
lib/pubsubhubbub.rb Normal file
View file

@ -0,0 +1,19 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class PubSubHubbub
H = {"User-Agent" => "PubSubHubbub Ruby", "Content-Type" => "application/x-www-form-urlencoded"}
def initialize(hub, options={})
@headers = H.merge(options[:head]) if options[:head]
@hub = hub.kind_of?(URI) ? hub : URI::parse(hub)
end
def publish(feed)
RestClient.post @hub, :headers => H, 'hub.url' => feed, 'hub.mode' => 'publish'
end
end