From 24eae3104ea8df29ad97c20f2c1f8d2d3156ac7a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 27 Jun 2016 14:09:34 +0200 Subject: [PATCH] Improved visualisation of delivery failed message. --- .../app/controllers/ticket_zoom/article_view.coffee | 9 ++++++++- .../ticket_zoom/article_view_delivery_failed.jst.eco | 7 +++++++ .../ticket/article/communicate_email/background_job.rb | 7 +++---- .../article/communicate_facebook/background_job.rb | 5 ++--- .../ticket/article/communicate_twitter/background_job.rb | 3 +-- 5 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 app/assets/javascripts/app/views/ticket_zoom/article_view_delivery_failed.jst.eco 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 ed04fb77d..45b3b160e 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,14 @@ class ArticleViewItem extends App.ObserverController article['html'] = App.Utils.text2html(body) article['html'] = article['html'].replace(signatureDetected, '') - if article.sender.name is 'System' && !article.preferences.delivery_message + if article.preferences.delivery_message + @html App.view('ticket_zoom/article_view_delivery_failed')( + ticket: @ticket + article: article + isCustomer: @isRole('Customer') + ) + return + if article.sender.name is 'System' #if article.sender.name is 'System' && article.preferences.perform_origin is 'trigger' @html App.view('ticket_zoom/article_view_system')( ticket: @ticket diff --git a/app/assets/javascripts/app/views/ticket_zoom/article_view_delivery_failed.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/article_view_delivery_failed.jst.eco new file mode 100644 index 000000000..abd713f2a --- /dev/null +++ b/app/assets/javascripts/app/views/ticket_zoom/article_view_delivery_failed.jst.eco @@ -0,0 +1,7 @@ +
+
+
+ <%- @T('Delivery failed') %>: "<%= @article.body %>" +
+
+
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 5b7de0e54..aa1b21d03 100644 --- a/app/models/observer/ticket/article/communicate_email/background_job.rb +++ b/app/models/observer/ticket/article/communicate_email/background_job.rb @@ -23,9 +23,9 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob # send email if !ticket.group.email_address_id - log_error(record, "Unable to send email, no email address definde for group id '#{ticket.group.id}'") + log_error(record, "No email address definde for group id '#{ticket.group.id}'!") elsif !ticket.group.email_address.channel_id - log_error(record, "Unable to send email, no channel definde for email_address id '#{ticket.group.email_address_id}'") + log_error(record, "No channel definde for email_address id '#{ticket.group.email_address_id}'!") end channel = ticket.group.email_address.channel @@ -129,7 +129,7 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob Ticket::Article.create( ticket_id: local_record.ticket_id, content_type: 'text/plain', - body: "Unable to send email to '#{recipient_list}'\n#{message}", + body: "Unable to send email to '#{recipient_list}': #{message}", internal: true, sender: Ticket::Article::Sender.find_by(name: 'System'), type: Ticket::Article::Type.find_by(name: 'note'), @@ -140,7 +140,6 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob updated_by_id: 1, created_by_id: 1, ) - return end raise message 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 e6cd4cdf8..5c53fab39 100644 --- a/app/models/observer/ticket/article/communicate_facebook/background_job.rb +++ b/app/models/observer/ticket/article/communicate_facebook/background_job.rb @@ -46,7 +46,7 @@ class Observer::Ticket::Article::CommunicateFacebook::BackgroundJob end if !post - log_error(article, 'Unable to send message to facebook') + log_error(article, 'Got no post!') return end @@ -73,7 +73,7 @@ class Observer::Ticket::Article::CommunicateFacebook::BackgroundJob Ticket::Article.create( ticket_id: local_record.ticket_id, content_type: 'text/plain', - body: "Unable to send tweet: #{message}", + body: "Unable to send post: #{message}", internal: true, sender: Ticket::Article::Sender.find_by(name: 'System'), type: Ticket::Article::Type.find_by(name: 'note'), @@ -84,7 +84,6 @@ class Observer::Ticket::Article::CommunicateFacebook::BackgroundJob updated_by_id: 1, created_by_id: 1, ) - return end raise message 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 fce89f0a3..f27df7ae6 100644 --- a/app/models/observer/ticket/article/communicate_twitter/background_job.rb +++ b/app/models/observer/ticket/article/communicate_twitter/background_job.rb @@ -31,7 +31,7 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob return end if !tweet - log_error(article, 'Unable to send message to twitter') + log_error(article, 'Got no tweet!') return end @@ -94,7 +94,6 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob updated_by_id: 1, created_by_id: 1, ) - return end raise message