class Vines::Stanza::Presence::Subscribed
Public Instance Methods
process()
click to toggle source
# File lib/vines/stanza/presence/subscribed.rb, line 9 def process stamp_from inbound? ? process_inbound : process_outbound end
process_inbound()
click to toggle source
# File lib/vines/stanza/presence/subscribed.rb, line 24 def process_inbound to = stamp_to user = storage(to.domain).find_user(to) follower = user.follower(stream.user.jid) if user return unless follower && follower.can_subscribe? follower.subscribe_to storage(to.domain).save_user(user) stream.update_user_streams(user) broadcast_subscription_change(follower) end
process_outbound()
click to toggle source
# File lib/vines/stanza/presence/subscribed.rb, line 14 def process_outbound to = stamp_to stream.user.add_subscription_from(to) storage.save_user(stream.user) stream.update_user_streams(stream.user) local? ? process_inbound : route send_roster_push(to) send_known_presence(to) end
Private Instance Methods
send_known_presence(to)
click to toggle source
After approving a follower's subscription to this user's presence, broadcast this user's most recent presence stanzas to the follower.
# File lib/vines/stanza/presence/subscribed.rb, line 39 def send_known_presence(to) stanzas = stream.available_resources(stream.user.jid).map do |stream| stream.last_broadcast_presence.clone.tap do |node| node['from'] = stream.user.jid.to_s node['id'] = Kit.uuid end end broadcast_to_available_resources(stanzas, to) end