Patch #31283 » mail_handler-plus_ticketid.patch
| redmine34/app/models/mail_handler.rb Tue Apr 30 13:33:29 2019 +0200 → redmine34/app/models/mail_handler.rb Tue Apr 30 16:01:21 2019 +0200 | ||
|---|---|---|
|
def dispatch
|
||
|
headers = [email.in_reply_to, email.references].flatten.compact
|
||
|
subject = email.subject.to_s
|
||
|
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
|
||
|
if issue = get_issue_from_receiver_addresses
|
||
|
receive_issue_reply(issue.id)
|
||
|
elsif headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
|
||
|
klass, object_id = $1, $2.to_i
|
||
|
method_name = "receive_#{klass}_reply"
|
||
|
if self.class.private_instance_methods.collect(&:to_s).include?(method_name)
|
||
| ... | ... | |
|
keyword
|
||
|
end
|
||
|
def get_issue_from_receiver_addresses
|
||
|
local, domain = Setting.mail_from.to_s.split("@")
|
||
|
return nil unless local && domain && Setting.plus_ticketid?
|
||
|
local = Regexp.escape(local)
|
||
|
[:to, :cc, :bcc].each do |field|
|
||
|
header = @email[field]
|
||
|
next if header.blank? || header.field.blank? || !header.field.respond_to?(:addrs)
|
||
|
header.field.addrs.each do |addr|
|
||
|
if addr.domain.to_s.casecmp(domain)==0 && addr.local.to_s =~ /\A#{local}\+([\d]+)\z/
|
||
|
if issue = Issue.find_by_id($1)
|
||
|
return issue
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
nil
|
||
|
end
|
||
|
def get_project_from_receiver_addresses
|
||
|
local, domain = handler_options[:project_from_subaddress].to_s.split("@")
|
||
|
return nil unless local && domain
|
||
| redmine34/app/models/mailer.rb Tue Apr 30 13:33:29 2019 +0200 → redmine34/app/models/mailer.rb Tue Apr 30 16:01:21 2019 +0200 | ||
|---|---|---|
|
end
|
||
|
def mail(headers={}, &block)
|
||
|
headers.reverse_merge! 'X-Mailer' => 'Redmine',
|
||
|
reply_to = nil
|
||
|
if Setting.plus_ticketid? && @issue && @issue.id?
|
||
|
reply_to = Setting.mail_from.to_s.sub('@', "+#{@issue.id}@")
|
||
|
end
|
||
|
headers.reverse_merge!({'X-Mailer' => 'Redmine',
|
||
|
'X-Redmine-Host' => Setting.host_name,
|
||
|
'X-Redmine-Site' => Setting.app_title,
|
||
|
'X-Auto-Response-Suppress' => 'All',
|
||
|
'Auto-Submitted' => 'auto-generated',
|
||
|
'Reply-To' => reply_to,
|
||
|
'From' => Setting.mail_from,
|
||
|
'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
|
||
|
}.reject{ |k,v| v.nil? })
|
||
|
# Replaces users with their email addresses
|
||
|
[:to, :cc, :bcc].each do |key|
|
||
| redmine34/app/views/settings/_notifications.html.erb Tue Apr 30 13:33:29 2019 +0200 → redmine34/app/views/settings/_notifications.html.erb Tue Apr 30 16:01:21 2019 +0200 | ||
|---|---|---|
|
<p><%= setting_check_box :plain_text_mail %></p>
|
||
|
<p><%= setting_check_box :plus_ticketid %></p>
|
||
|
<p><%= setting_select(:default_notification_option, User.valid_notification_options.collect {|o| [l(o.last), o.first.to_s]}) %></p>
|
||
|
</div>
|
||
| redmine34/config/locales/en.yml Tue Apr 30 13:33:29 2019 +0200 → redmine34/config/locales/en.yml Tue Apr 30 16:01:21 2019 +0200 | ||
|---|---|---|
|
setting_mail_from: Emission email address
|
||
|
setting_bcc_recipients: Blind carbon copy recipients (bcc)
|
||
|
setting_plain_text_mail: Plain text mail (no HTML)
|
||
|
setting_plus_ticketid: Append ticket id to sender address (Reply-To)
|
||
|
setting_host_name: Host name and path
|
||
|
setting_text_formatting: Text formatting
|
||
|
setting_wiki_compression: Wiki history compression
|
||
| redmine34/config/settings.yml Tue Apr 30 13:33:29 2019 +0200 → redmine34/config/settings.yml Tue Apr 30 16:01:21 2019 +0200 | ||
|---|---|---|
|
default: 1
|
||
|
plain_text_mail:
|
||
|
default: 0
|
||
|
plus_ticketid:
|
||
|
default: 0
|
||
|
text_formatting:
|
||
|
default: textile
|
||
|
cache_formatted_text:
|
||