From 567daf00537ce07ea19c6c58087d0a1c39acb754 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 24 Sep 2018 15:21:21 +0200 Subject: [PATCH] Fixed issue #2253 - Unable to index elasticsearch if article.preferences[:delivery_status_message] has no utf8 charset. --- .../observer/ticket/article/communicate_email/background_job.rb | 2 +- .../ticket/article/communicate_facebook/background_job.rb | 2 +- .../ticket/article/communicate_telegram/background_job.rb | 2 +- .../ticket/article/communicate_twitter/background_job.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 1b2e14f29..54114744c 100644 --- a/app/models/observer/ticket/article/communicate_email/background_job.rb +++ b/app/models/observer/ticket/article/communicate_email/background_job.rb @@ -121,7 +121,7 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob local_record.preferences['delivery_channel_id'] = channel.id end local_record.preferences['delivery_status'] = 'fail' - local_record.preferences['delivery_status_message'] = message + local_record.preferences['delivery_status_message'] = message.encode!('UTF-8', 'UTF-8', invalid: :replace, replace: '?') local_record.preferences['delivery_status_date'] = Time.zone.now local_record.save! Rails.logger.error 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 c48d61e78..b3a268f86 100644 --- a/app/models/observer/ticket/article/communicate_facebook/background_job.rb +++ b/app/models/observer/ticket/article/communicate_facebook/background_job.rb @@ -66,7 +66,7 @@ class Observer::Ticket::Article::CommunicateFacebook::BackgroundJob def log_error(local_record, message) local_record.preferences['delivery_status'] = 'fail' - local_record.preferences['delivery_status_message'] = message + local_record.preferences['delivery_status_message'] = message.encode!('UTF-8', 'UTF-8', invalid: :replace, replace: '?') local_record.preferences['delivery_status_date'] = Time.zone.now local_record.save Rails.logger.error message diff --git a/app/models/observer/ticket/article/communicate_telegram/background_job.rb b/app/models/observer/ticket/article/communicate_telegram/background_job.rb index 1a0929472..9e1543cde 100644 --- a/app/models/observer/ticket/article/communicate_telegram/background_job.rb +++ b/app/models/observer/ticket/article/communicate_telegram/background_job.rb @@ -87,7 +87,7 @@ class Observer::Ticket::Article::CommunicateTelegram::BackgroundJob def log_error(local_record, message) local_record.preferences['delivery_status'] = 'fail' - local_record.preferences['delivery_status_message'] = message + local_record.preferences['delivery_status_message'] = message.encode!('UTF-8', 'UTF-8', invalid: :replace, replace: '?') local_record.preferences['delivery_status_date'] = Time.zone.now local_record.save Rails.logger.error 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 fbd77f341..b7f3257b4 100644 --- a/app/models/observer/ticket/article/communicate_twitter/background_job.rb +++ b/app/models/observer/ticket/article/communicate_twitter/background_job.rb @@ -105,7 +105,7 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob def log_error(local_record, message) local_record.preferences['delivery_status'] = 'fail' - local_record.preferences['delivery_status_message'] = message + local_record.preferences['delivery_status_message'] = message.encode!('UTF-8', 'UTF-8', invalid: :replace, replace: '?') local_record.preferences['delivery_status_date'] = Time.zone.now local_record.save Rails.logger.error message