Sha256: c4523b5dc9f541533e0ef468b0c17f4305c3423b28a03ad8294b1e75267151eb

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

module Mack
  module Notifier
    module Adapters # :nodoc:
      
      class XmppMsgContainer 
        attr_accessor :messages
        attr_accessor :recipients
        def initialize
          self.messages = []
          self.recipients = []
        end
        
        def find_message_by_recipient(rcpt)
          self.messages.find { |x| x.to.to_s == rcpt.to_s }
        end
        
      end
      
      # All mail adapters need to extend this class.
      class Xmpp < Mack::Notifier::Adapters::Base
        include Jabber
        
        # The transformed (ie, converted, object)
        def transformed
          raise Mack::Errors::UnconvertedNotifier.new if @xmpp_msg.nil?
          return @xmpp_container
        end
        
        # Convert the Mack::Notifier object to the adapted object.
        def convert
          settings = configatron.mack.notifier.xmpp_settings
          arr = [mack_notifier.to].flatten
          @xmpp_container = XmppMsgContainer.new
          @xmpp_container.recipients = arr
          
          arr.each do |rcpt|
            xmpp_msg = Message::new
            xmpp_msg.set_type(:normal)
            xmpp_msg.set_to(rcpt)
            xmpp_msg.set_from(mack_notifier.from)
            xmpp_msg.set_subject(mack_notifier.subject)
            xmpp_msg.set_type(settings.message_type)
            unless mack_notifier.body(:plain).blank?
              xmpp_msg.set_body(mack_notifier.body(:plain))
            end

            @xmpp_container.messages << xmpp_msg
          end
          
          return @xmpp_container
        end
        
        # The RAW encoded String ready for delivery via SMTP, Sendmail, etc...
        def deliverable
          return @xmpp_container
        end
        
      end # Base
    end # Adapters
  end # Notifier
end # Mack

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mack-notifier-0.8.1 lib/mack-notifier/adapters/xmpp_msg.rb
mack-notifier-0.8.2 lib/mack-notifier/adapters/xmpp_msg.rb
mack-notifier-0.8.3 lib/mack-notifier/adapters/xmpp_msg.rb
mack-notifier-0.8.3.1 lib/mack-notifier/adapters/xmpp_msg.rb