Skip to content

Instantly share code, notes, and snippets.

@aconbere
Created October 8, 2009 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aconbere/205507 to your computer and use it in GitHub Desktop.
Save aconbere/205507 to your computer and use it in GitHub Desktop.
#+++ pubsub_presence_controller.rb
class Pubsub_presenceController < Babylon::Base::Controller
@@nodes = []
def nodes
Babylon.logger.debug { "NODES" }
@from = Babylon.config["jid"]
@to = Babylon.config["pubsub_jid"]
@id = "nodereq"
@@nodes = @stanza.nodes.map {|i| i.node}
# collects the node request response, and for each node, asks for a list of subscribers
@@nodes.each do |n|
render_evaluate_and_send(:file => "subscription_request.xml.builder", :locals => {:node => n})
end
end
#+++ subscription_request.xml.builder
xml.iq(:type => 'get', :from => @from, :to => @to, :id => @id) do
xml.pubsub(:xmlns => 'http://jabber.org/protocol/pubsub#owner') do
xml.subscriptions(:node => @node)
end
end
#+++ renders
#
#<iq type="get" from="presence.pubsub.localhost" to="pubsub.localhost" id="nodereq">
# <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
# <subscriptions node=""/>
# </pubsub>
#</iq>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment