Class: Vines::Stanza::Presence::Subscribe
- Inherits:
-
Vines::Stanza::Presence
- Object
- Vines::Stanza
- Vines::Stanza::Presence
- Vines::Stanza::Presence::Subscribe
- Defined in:
- lib/vines/stanza/presence/subscribe.rb
Constant Summary
Constants inherited from Vines::Stanza::Presence
Constants inherited from Vines::Stanza
Instance Attribute Summary
Attributes inherited from Vines::Stanza
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?, #method_missing, register, #route, #router, #send_unavailable, #storage, #unavailable
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
#process ⇒ Object
9 10 11 |
# File 'lib/vines/stanza/presence/subscribe.rb', line 9 def process inbound? ? process_inbound : process_outbound end |
#process_inbound ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vines/stanza/presence/subscribe.rb', line 28 def process_inbound self['from'] = stream.user.jid..to_s to = stamp_to contact = storage(to.domain).find_user(to) if contact.nil? auto_reply_to_subscription_request(to, 'unsubscribed') elsif contact.subscribed_from?(stream.user.jid) auto_reply_to_subscription_request(to, 'subscribed') else recipients = router.available_resources(to) if recipients.empty? # TODO store subscription request per RFC 6121 3.1.3 #4 else recipients.each {|stream| stream.write(@node) } end end end |
#process_outbound ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vines/stanza/presence/subscribe.rb', line 13 def process_outbound self['from'] = stream.user.jid..to_s to = stamp_to local? ? process_inbound : route stream.user.request_subscription(to) storage.save_user(stream.user) stream.update_user_streams(stream.user) contact = stream.user.contact(to) router.interested_resources(stream.user.jid).each do |recipient| contact.send_roster_push(recipient) end end |