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 | ||
|---|---|---|
| 159 | 159 |
def dispatch |
| 160 | 160 |
headers = [email.in_reply_to, email.references].flatten.compact |
| 161 | 161 |
subject = email.subject.to_s |
| 162 |
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
|
|
| 162 |
if issue = get_issue_from_receiver_addresses |
|
| 163 |
receive_issue_reply(issue.id) |
|
| 164 |
elsif headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
|
|
| 163 | 165 |
klass, object_id = $1, $2.to_i |
| 164 | 166 |
method_name = "receive_#{klass}_reply"
|
| 165 | 167 |
if self.class.private_instance_methods.collect(&:to_s).include?(method_name) |
| ... | ... | |
| 377 | 379 |
keyword |
| 378 | 380 |
end |
| 379 | 381 | |
| 382 |
def get_issue_from_receiver_addresses |
|
| 383 |
local, domain = Setting.mail_from.to_s.split("@")
|
|
| 384 |
return nil unless local && domain && Setting.plus_ticketid? |
|
| 385 |
local = Regexp.escape(local) |
|
| 386 | ||
| 387 |
[:to, :cc, :bcc].each do |field| |
|
| 388 |
header = @email[field] |
|
| 389 |
next if header.blank? || header.field.blank? || !header.field.respond_to?(:addrs) |
|
| 390 |
header.field.addrs.each do |addr| |
|
| 391 |
if addr.domain.to_s.casecmp(domain)==0 && addr.local.to_s =~ /\A#{local}\+([\d]+)\z/
|
|
| 392 |
if issue = Issue.find_by_id($1) |
|
| 393 |
return issue |
|
| 394 |
end |
|
| 395 |
end |
|
| 396 |
end |
|
| 397 |
end |
|
| 398 |
nil |
|
| 399 |
end |
|
| 400 | ||
| 380 | 401 |
def get_project_from_receiver_addresses |
| 381 | 402 |
local, domain = handler_options[:project_from_subaddress].to_s.split("@")
|
| 382 | 403 |
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 | ||
|---|---|---|
| 441 | 441 |
end |
| 442 | 442 | |
| 443 | 443 |
def mail(headers={}, &block)
|
| 444 |
headers.reverse_merge! 'X-Mailer' => 'Redmine', |
|
| 444 |
reply_to = nil |
|
| 445 |
if Setting.plus_ticketid? && @issue && @issue.id? |
|
| 446 |
reply_to = Setting.mail_from.to_s.sub('@', "+#{@issue.id}@")
|
|
| 447 |
end |
|
| 448 |
headers.reverse_merge!({'X-Mailer' => 'Redmine',
|
|
| 445 | 449 |
'X-Redmine-Host' => Setting.host_name, |
| 446 | 450 |
'X-Redmine-Site' => Setting.app_title, |
| 447 | 451 |
'X-Auto-Response-Suppress' => 'All', |
| 448 | 452 |
'Auto-Submitted' => 'auto-generated', |
| 453 |
'Reply-To' => reply_to, |
|
| 449 | 454 |
'From' => Setting.mail_from, |
| 450 | 455 |
'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
|
| 456 |
}.reject{ |k,v| v.nil? })
|
|
| 451 | 457 | |
| 452 | 458 |
# Replaces users with their email addresses |
| 453 | 459 |
[: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 | ||
|---|---|---|
| 8 | 8 | |
| 9 | 9 |
<p><%= setting_check_box :plain_text_mail %></p> |
| 10 | 10 | |
| 11 |
<p><%= setting_check_box :plus_ticketid %></p> |
|
| 12 | ||
| 11 | 13 |
<p><%= setting_select(:default_notification_option, User.valid_notification_options.collect {|o| [l(o.last), o.first.to_s]}) %></p>
|
| 12 | 14 | |
| 13 | 15 |
</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 | ||
|---|---|---|
| 388 | 388 |
setting_mail_from: Emission email address |
| 389 | 389 |
setting_bcc_recipients: Blind carbon copy recipients (bcc) |
| 390 | 390 |
setting_plain_text_mail: Plain text mail (no HTML) |
| 391 |
setting_plus_ticketid: Append ticket id to sender address (Reply-To) |
|
| 391 | 392 |
setting_host_name: Host name and path |
| 392 | 393 |
setting_text_formatting: Text formatting |
| 393 | 394 |
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 | ||
|---|---|---|
| 84 | 84 |
default: 1 |
| 85 | 85 |
plain_text_mail: |
| 86 | 86 |
default: 0 |
| 87 |
plus_ticketid: |
|
| 88 |
default: 0 |
|
| 87 | 89 |
text_formatting: |
| 88 | 90 |
default: textile |
| 89 | 91 |
cache_formatted_text: |