Class: Vines::Stanza::Presence::Probe

Inherits:
Vines::Stanza::Presence show all
Defined in:
lib/vines/stanza/presence/probe.rb

Constant Summary

Constants inherited from Vines::Stanza::Presence

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::Presence

#inbound?, #inbound_broadcast_presence, #outbound?, #outbound_broadcast_presence

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



9
10
11
# File 'lib/vines/stanza/presence/probe.rb', line 9

def process
  inbound? ? process_inbound : process_outbound
end

#process_inboundObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vines/stanza/presence/probe.rb', line 18

def process_inbound
  to = validate_to
  raise StanzaErrors::BadRequest.new(self, 'modify') unless to

  user = storage(to.domain).find_user(to)
  unless user && user.subscribed_from?(stream.user.jid)
    auto_reply_to_subscription_request(to.bare, 'unsubscribed')
  else
    stream.available_resources(to).each do |recipient|
      el = recipient.last_broadcast_presence.clone
      el['from'] = recipient.user.jid.to_s
      el['to'] = stream.user.jid.to_s
      stream.write(el)
    end
  end
end

#process_outboundObject



13
14
15
16
# File 'lib/vines/stanza/presence/probe.rb', line 13

def process_outbound
  self['from'] = stream.user.jid.to_s
  local? ? process_inbound : route
end