From 4bd1f8ebf1ce3b77cbaf3527a607c6680bc8cd40 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 30 Aug 2015 22:15:23 +0200 Subject: [PATCH] Fixed creation of article.message_id_md5 right after generating message_id. --- .../observer/ticket/article/fillup_from_email.rb | 3 +++ app/models/ticket/article.rb | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/models/observer/ticket/article/fillup_from_email.rb b/app/models/observer/ticket/article/fillup_from_email.rb index 55bbbdc98..d0735373b 100644 --- a/app/models/observer/ticket/article/fillup_from_email.rb +++ b/app/models/observer/ticket/article/fillup_from_email.rb @@ -30,6 +30,9 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer fqdn = Setting.get('fqdn') record.message_id = '<' + DateTime.current.to_s(:number) + '.' + record.ticket_id.to_s + '.' + rand(999_999).to_s() + '@' + fqdn + '>' + # generate message_id_md5 + record.check_message_id_md5 + # set sender email_address = ticket.group.email_address if !email_address diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb index 194bc89d4..66096a282 100644 --- a/app/models/ticket/article.rb +++ b/app/models/ticket/article.rb @@ -30,6 +30,13 @@ class Ticket::Article < ApplicationModel preferences: true, } + # fillup md5 of message id to search easier on very long message ids + def check_message_id_md5 + return if !message_id + return if message_id_md5 + self.message_id_md5 = Digest::MD5.hexdigest(message_id.to_s) + end + private # strip not wanted chars @@ -38,13 +45,6 @@ class Ticket::Article < ApplicationModel subject.gsub!(/\s|\t|\r/, ' ') end - # fillup md5 of message id to search easier on very long message ids - def check_message_id_md5 - return if !message_id - return if message_id_md5 - self.message_id_md5 = Digest::MD5.hexdigest(message_id.to_s) - end - class Flag < ApplicationModel end