From 7b9889abe70aa3a1abc6df6dfa35f3655d8dd9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 27 Feb 2015 10:13:31 +0100 Subject: [PATCH] patch mailer to fix mail threading (#6582) --- init.rb | 3 ++- lib/mailer_patch.rb | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 lib/mailer_patch.rb diff --git a/init.rb b/init.rb index 35baeac..abb1b5c 100644 --- a/init.rb +++ b/init.rb @@ -2,9 +2,10 @@ require 'redmine' require_dependency 'welcome_controller_patch' require_dependency 'project_model_patch' +require_dependency 'mailer_patch' Redmine::Plugin.register :redmine_entrouvert do name 'Redmine Entr\'ouvert plugin' author 'Entr\'ouvert' - version '0.1.0' + version '0.2.0' end diff --git a/lib/mailer_patch.rb b/lib/mailer_patch.rb new file mode 100644 index 0000000..8388f91 --- /dev/null +++ b/lib/mailer_patch.rb @@ -0,0 +1,23 @@ +module MailerPatch + def self.included(base) + base.class_eval do + def self.token_for(object, rand=true) + timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on) + hash = [ + "redmine", + "#{object.class.name.demodulize.underscore}-#{object.id}", + timestamp.strftime("%Y%m%d%H%M%S") + ] + # disabled, see https://dev.entrouvert.org/issues/6582 + #if rand + # hash << Redmine::Utils.random_hex(8) + #end + host = Setting.mail_from.to_s.gsub(%r{^.*@}, '') + host = "#{::Socket.gethostname}.redmine" if host.empty? + "#{hash.join('.')}@#{host}" + end + end + end +end + +Mailer.send(:include, MailerPatch)