Class: Vines::Stanza::PubSub::Create

Inherits:
Vines::Stanza::PubSub show all
Defined in:
lib/vines/stanza/pubsub/create.rb

Constant Summary collapse

NS =
NAMESPACES[:pubsub]

Constants inherited from Iq

Iq::VALID_TYPES

Constants inherited from Vines::Stanza

EMPTY, ROUTABLE_STANZAS

Instance Attribute Summary

Attributes inherited from Vines::Stanza

#stream

Instance Method Summary collapse

Methods inherited from Iq

#to_result

Methods inherited from Vines::Stanza

#broadcast, from_node, #initialize, #local?, #local_jid?, #method_missing, register, #route, #router, #send_unavailable, #storage, #to_pubsub_domain?, #unavailable, #validate_from, #validate_to

Constructor Details

This class inherits a constructor from Vines::Stanza

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Vines::Stanza

Instance Method Details

#processObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vines/stanza/pubsub/create.rb', line 11

def process
  return if route_iq || !allowed?
  validate_to_address

  node = self.xpath('ns:pubsub/ns:create', 'ns' => NS)
  raise StanzaErrors::BadRequest.new(self, 'modify') if node.size != 1
  node = node.first

  id = (node['node'] || '').strip
  id = Kit.uuid if id.empty?
  raise StanzaErrors::Conflict.new(self, 'cancel') if pubsub.node?(id)
  pubsub.add_node(id)
  send_result_iq(id)
end