Sha256: 38715e01c26ddaeec8f4f655fd2e3ef959d603b32712cf3cbca550d4533b1631

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# encoding: UTF-8

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

        def process
          stamp_from
          inbound? ? process_inbound : process_outbound
        end

        def process_outbound
          to = stamp_to
          return unless stream.user.subscribed_from?(to)
          send_unavailable(stream.user.jid, to)
          stream.user.remove_subscription_from(to)
          storage.save_user(stream.user)
          stream.update_user_streams(stream.user)
          local? ? process_inbound : route
          send_roster_push(to)
        end

        def process_inbound
          to = stamp_to
          user = storage(to.domain).find_user(to)
          return unless user && user.subscribed_to?(stream.user.jid)
          follower = user.follower(stream.user.jid)
          follower.unsubscribe_to
          storage(to.domain).save_user(user)
          stream.update_user_streams(user)
          broadcast_subscription_change(follower)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lygneo-vines-0.1.5 lib/vines/stanza/presence/unsubscribed.rb
lygneo-vines-0.1.1 lib/vines/stanza/presence/unsubscribed.rb