From 69420df8a5743d0439389473a101a0ebc1878c02 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 1 Jan 2015 01:26:17 +0100 Subject: [PATCH] Moved from class to module for sending emails. --- app/models/channel/email_send.rb | 4 ++-- .../ticket/article/communicate_email/background_job.rb | 7 +++---- app/models/observer/ticket/notification.rb | 2 +- lib/notification_factory.rb | 3 ++- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/channel/email_send.rb b/app/models/channel/email_send.rb index 2cee1e27b..18bfba6b6 100644 --- a/app/models/channel/email_send.rb +++ b/app/models/channel/email_send.rb @@ -2,8 +2,8 @@ require 'net/imap' -class Channel::EmailSend - def send(attr, notification = false) +module Channel::EmailSend + def self.send(attr, notification = false) channel = Channel.where( :area => 'Email::Outbound', :active => true ).first begin c = eval 'Channel::' + channel[:adapter] + '.new' diff --git a/app/models/observer/ticket/article/communicate_email/background_job.rb b/app/models/observer/ticket/article/communicate_email/background_job.rb index aecfba297..2086515fe 100644 --- a/app/models/observer/ticket/article/communicate_email/background_job.rb +++ b/app/models/observer/ticket/article/communicate_email/background_job.rb @@ -6,12 +6,11 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob record = Ticket::Article.find( @article_id ) # build subject - ticket = Ticket.lookup( :id => record.ticket_id ) + ticket = Ticket.lookup( :id => record.ticket_id ) subject = ticket.subject_build( record.subject ) # send email - a = Channel::EmailSend.new - message = a.send( + message = Channel::EmailSend.send( { :message_id => record.message_id, :in_reply_to => record.in_reply_to, @@ -58,4 +57,4 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob ) end end -end +end \ No newline at end of file diff --git a/app/models/observer/ticket/notification.rb b/app/models/observer/ticket/notification.rb index 93ecb7977..7f0eca37f 100644 --- a/app/models/observer/ticket/notification.rb +++ b/app/models/observer/ticket/notification.rb @@ -236,4 +236,4 @@ class Observer::Ticket::Notification < ActiveRecord::Observer # puts @a.inspect # AuditTrail.new(record, "UPDATED") end -end +end \ No newline at end of file diff --git a/lib/notification_factory.rb b/lib/notification_factory.rb index 416fca12b..38e15c8ea 100644 --- a/lib/notification_factory.rb +++ b/lib/notification_factory.rb @@ -95,7 +95,8 @@ module NotificationFactory def self.send(data) sender = Setting.get('notification_sender') Rails.logger.info "NOTICE: SEND NOTIFICATION TO: #{data[:recipient][:email]} (from #{sender})" - Channel::EmailSend.new.send( + + Channel::EmailSend.send( { # :in_reply_to => self.in_reply_to, :from => sender,