Class: Vines::Stanza::Iq::DiscoInfo

Inherits:
Query show all
Defined in:
lib/vines/stanza/iq/disco_info.rb

Constant Summary collapse

NS =
NAMESPACES[:disco_info]

Constants inherited from Vines::Stanza::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 Vines::Stanza::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
25
26
27
28
29
# File 'lib/vines/stanza/iq/disco_info.rb', line 11

def process
  return if route_iq || !allowed?
  result = to_result.tap do |el|
    el << el.document.create_element('query') do |query|
      query.default_namespace = NS
      if to_pubsub_domain?
        identity(query, 'pubsub', 'service')
        pubsub = [:pubsub_create, :pubsub_delete, :pubsub_instant, :pubsub_item_ids, :pubsub_publish, :pubsub_subscribe]
        features(query, :disco_info, :ping, :pubsub, *pubsub)
      else
        identity(query, 'server', 'im')
        features = [:disco_info, :disco_items, :ping, :vcard, :version]
        features << :storage if stream.config.private_storage?(validate_to || stream.domain)
        features(query, features)
      end
    end
  end
  stream.write(result)
end