diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index 5181d47a2..532501efe 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -359,7 +359,7 @@ class Table extends App.Controller class: 'table--light' bindRow: events: - 'click': openTicket + 'click': openTicket #bindCol: # customer_id: # events: diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee index 92a71239a..ed04fb77d 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee @@ -117,7 +117,8 @@ class ArticleViewItem extends App.ObserverController article['html'] = App.Utils.text2html(body) article['html'] = article['html'].replace(signatureDetected, '') - if article.sender.name is 'System' + if article.sender.name is 'System' && !article.preferences.delivery_message + #if article.sender.name is 'System' && article.preferences.perform_origin is 'trigger' @html App.view('ticket_zoom/article_view_system')( ticket: @ticket article: article 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 44286e3f5..5b7de0e54 100644 --- a/app/models/observer/ticket/article/communicate_email/background_job.rb +++ b/app/models/observer/ticket/article/communicate_email/background_job.rb @@ -58,7 +58,7 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob return end if !message - log_error(record, 'Unable to send email') + log_error(record, 'Unable to get sent email') return end @@ -113,13 +113,30 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob Rails.logger.error message if local_record.preferences['delivery_retry'] > 3 + + recipient_list = '' + [:to, :cc].each { |key| + + next if !local_record[key] + next if local_record[key] == '' + + if recipient_list != '' + recipient_list += ',' + end + recipient_list += local_record[key] + } + Ticket::Article.create( ticket_id: local_record.ticket_id, content_type: 'text/plain', - body: "Unable to send email: #{message}", + body: "Unable to send email to '#{recipient_list}'\n#{message}", internal: true, sender: Ticket::Article::Sender.find_by(name: 'System'), type: Ticket::Article::Type.find_by(name: 'note'), + preferences: { + delivery_article_id_related: local_record.id, + delivery_message: true, + }, updated_by_id: 1, created_by_id: 1, ) diff --git a/app/models/observer/ticket/article/communicate_facebook/background_job.rb b/app/models/observer/ticket/article/communicate_facebook/background_job.rb index 702208419..e6cd4cdf8 100644 --- a/app/models/observer/ticket/article/communicate_facebook/background_job.rb +++ b/app/models/observer/ticket/article/communicate_facebook/background_job.rb @@ -77,6 +77,10 @@ class Observer::Ticket::Article::CommunicateFacebook::BackgroundJob internal: true, sender: Ticket::Article::Sender.find_by(name: 'System'), type: Ticket::Article::Type.find_by(name: 'note'), + preferences: { + delivery_article_id_related: local_record.id, + delivery_message: true, + }, updated_by_id: 1, created_by_id: 1, ) diff --git a/app/models/observer/ticket/article/communicate_twitter/background_job.rb b/app/models/observer/ticket/article/communicate_twitter/background_job.rb index d8b664b92..fce89f0a3 100644 --- a/app/models/observer/ticket/article/communicate_twitter/background_job.rb +++ b/app/models/observer/ticket/article/communicate_twitter/background_job.rb @@ -87,6 +87,10 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob internal: true, sender: Ticket::Article::Sender.find_by(name: 'System'), type: Ticket::Article::Type.find_by(name: 'note'), + preferences: { + delivery_article_id_related: local_record.id, + delivery_message: true, + }, updated_by_id: 1, created_by_id: 1, ) diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 95c8eaa1d..53303c454 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -651,8 +651,8 @@ perform changes on ticket =end - def perform_changes(perform, log, item = nil) - logger.debug "Perform #{log} #{perform.inspect} on Ticket.find(#{id})" + def perform_changes(perform, perform_origin, item = nil) + logger.debug "Perform #{perform_origin} #{perform.inspect} on Ticket.find(#{id})" changed = false perform.each do |key, value| (object_name, attribute) = key.split('.', 2) @@ -770,6 +770,9 @@ perform changes on ticket internal: false, sender: Ticket::Article::Sender.find_by(name: 'System'), type: Ticket::Article::Type.find_by(name: 'email'), + preferences: { + perform_origin: perform_origin, + }, updated_by_id: 1, created_by_id: 1, ) diff --git a/test/integration/email_deliver_test.rb b/test/integration/email_deliver_test.rb index 728004728..34f6793e8 100644 --- a/test/integration/email_deliver_test.rb +++ b/test/integration/email_deliver_test.rb @@ -258,12 +258,15 @@ class EmailDeliverTest < ActiveSupport::TestCase Scheduler.worker(true) article2_lookup = Ticket::Article.find(article2.id) + article_delivery_system = ticket1.articles.last assert_equal(3, ticket1.articles.count) - assert_equal('System', ticket1.articles.last.sender.name) assert_equal(4, article2_lookup.preferences['delivery_retry']) assert_equal('fail', article2_lookup.preferences['delivery_status']) assert(article2_lookup.preferences['delivery_status_date']) assert(article2_lookup.preferences['delivery_status_message']) + assert_equal('System', article_delivery_system.sender.name) + assert_equal(true, article_delivery_system.preferences['delivery_message']) + assert_equal(article2.id, article_delivery_system.preferences['delivery_article_id_related']) end