From 1ccdf38fdde16421905f8419bb83f0e923bd16bc Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 17 Oct 2015 09:08:18 +0000 Subject: Mail Handler: add support for allow_override=all (#20543). git-svn-id: http://svn.redmine.org/redmine/trunk@14681 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mail_handler.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 007df6f2d..1364fdb97 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -29,11 +29,11 @@ class MailHandler < ActionMailer::Base options[:issue] ||= {} + options[:allow_override] ||= [] if options[:allow_override].is_a?(String) - options[:allow_override] = options[:allow_override].split(',').collect(&:strip) + options[:allow_override] = options[:allow_override].split(',') end - options[:allow_override] ||= [] - options[:allow_override].map!(&:downcase) + options[:allow_override].map! {|s| s.strip.downcase.gsub(/\s+/, '_')} # Project needs to be overridable if not specified options[:allow_override] << 'project' unless options[:issue].has_key?(:project) @@ -327,8 +327,11 @@ class MailHandler < ActionMailer::Base @keywords[attr] else @keywords[attr] = begin - if (options[:override] || handler_options[:allow_override].include?(attr.to_s.downcase)) && - (v = extract_keyword!(cleaned_up_text_body, attr, options[:format])) + override = options.key?(:override) ? + options[:override] : + (handler_options[:allow_override] & [attr.to_s.downcase.gsub(/\s+/, '_'), 'all']).present? + + if override && (v = extract_keyword!(cleaned_up_text_body, attr, options[:format])) v elsif !handler_options[:issue][attr].blank? handler_options[:issue][attr] -- cgit v1.2.3