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
diaspora-vines-0.2.0.develop.4 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.2.0.develop.3 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.2.0.develop.2 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.2.0.develop.1 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.1.28 lib/vines/stanza/presence/probe.rb
lygneo-vines-0.1.5 lib/vines/stanza/presence/probe.rb
lygneo-vines-0.1.1 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.1.27 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.1.26 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.1.25 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.1.24 lib/vines/stanza/presence/probe.rb
vines-0.4.10 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.1.22 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.1.21 lib/vines/stanza/presence/probe.rb
diaspora-vines-0.1.2 lib/vines/stanza/presence/probe.rb
vines-0.4.9 lib/vines/stanza/presence/probe.rb
vines-0.4.8 lib/vines/stanza/presence/probe.rb
vines-0.4.7 lib/vines/stanza/presence/probe.rb
vines-0.4.6 lib/vines/stanza/presence/probe.rb
vinesmod-0.4.5.2 lib/vines/stanza/presence/probe.rb