def start_deferred_delivery_thread #:nodoc:
      Thread.new {
        loop {
          messages = [queue(:pending_messages).pop].flatten
          messages.each do |message|
            if subscribed_to?(message[:to])
              deliver(message[:to], message[:message], message[:type])
            else
              queue(:pending_messages) << message
            end
          end
        }
      }
    end
def start_deferred_delivery_thread #:nodoc:
      Thread.new {
        loop {
          messages = [queue(:pending_messages).pop].flatten
          messages.each do |message|
            if subscribed_to?(message[:to])
              deliver(message[:to], message[:message], message[:type])
            else
              queue(:pending_messages) << message
            end
          end
        }
      }
    end
This thread facilitates the delivery of messages to users who haven't yet
 accepted an invitation from us. When we attempt to deliver a message, if
 the user hasn't subscribed, we place the message in a queue for later
 delivery. Once a user has accepted our authorization request, we deliver
 any messages that have been queued up in the meantime.