Sha256: c2401140fca3bb97247fadfa56632878a18fefa781ce5700353e1362307ec03f

Contents?: true

Size: 747 Bytes

Versions: 6

Compression:

Stored size: 747 Bytes

Contents

require 'jabber4r/jabber4r'

class JabberNotify
  @@jabber = nil

  def self.send_message(user, subject, body, html)
    return if user.jabber.blank?

    begin
      STDERR.puts "** Sending #{body} to #{user.jabber} via jabber."
      message = session.new_message(user.jabber)
      message.subject = subject
      message.body = body
      message.xhtml = html
      message.send
    rescue => err
      logger.error "Attempt to use jabber failed: #{err.inspect}" if logger
    end
  end

  private
  def self.session
    return @@jabber if @@jabber

    address = this_blog.jabber_address
    unless address =~ /\//
      address = address + '/typo'
    end

    @@jabber ||= Jabber::Session.bind(address, this_blog.jabber_password)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
typo-3.99.0 lib/jabber_notify.rb
typo-3.99.1 lib/jabber_notify.rb
typo-3.99.3 lib/jabber_notify.rb
typo-3.99.2 lib/jabber_notify.rb
typo-3.99.4 lib/jabber_notify.rb
typo-4.0.0 lib/jabber_notify.rb