Sha256: d4e71c65c0223d7e0444ee87a764a83c48ee6c033a6b6a2e8dfceddd6e3b070d

Contents?: true

Size: 1008 Bytes

Versions: 30

Compression:

Stored size: 1008 Bytes

Contents

# encoding: UTF-8

module Vines
  class Stanza
    class Presence
      class Probe < Presence
        register "/presence[@type='probe']"

        def process
          inbound? ? process_inbound : process_outbound
        end

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

        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
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
vinesmod-0.4.5 lib/vines/stanza/presence/probe.rb
vines-0.4.5 lib/vines/stanza/presence/probe.rb
vines-0.4.4 lib/vines/stanza/presence/probe.rb
vines-0.4.3 lib/vines/stanza/presence/probe.rb
vines-0.4.2 lib/vines/stanza/presence/probe.rb
vines-0.4.1 lib/vines/stanza/presence/probe.rb
vines-0.4.0 lib/vines/stanza/presence/probe.rb
vines-0.3.2 lib/vines/stanza/presence/probe.rb
vines-0.3.1 lib/vines/stanza/presence/probe.rb
vines-0.3.0 lib/vines/stanza/presence/probe.rb