patch mailer to fix mail threading (#6582)

This commit is contained in:
Frédéric Péters 2015-02-27 10:13:31 +01:00
parent a763ab6b96
commit 7b9889abe7
2 changed files with 25 additions and 1 deletions

View File

@ -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

23
lib/mailer_patch.rb Normal file
View File

@ -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)