diff -r 9484216289fe app/models/mail_handler.rb --- a/app/models/mail_handler.rb Fri Mar 25 13:36:42 2011 +0600 +++ b/app/models/mail_handler.rb Tue Mar 29 13:36:24 2011 +0700 @@ -35,6 +35,9 @@ @@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project) # Status overridable by default @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status) + + @@handler_options[:watchers] = @@handler_options[:watchers].split(',').collect(&:strip) if @@handler_options[:watchers].is_a?(String) + @@handler_options[:watchers] ||= [] @@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false) super email @@ -210,7 +213,7 @@ # appropriate permission def add_watchers(obj) if user.allowed_to?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project) - addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase} + addresses = ([email.to, email.cc] + @@handler_options[:watchers]).flatten.compact.uniq.collect {|a| a.strip.downcase} unless addresses.empty? watchers = User.active.find(:all, :conditions => ['LOWER(mail) IN (?)', addresses]) watchers.each {|w| obj.add_watcher(w)} diff -r 9484216289fe lib/tasks/email.rake --- a/lib/tasks/email.rake Fri Mar 25 13:36:42 2011 +0600 +++ b/lib/tasks/email.rake Tue Mar 29 13:36:24 2011 +0700 @@ -39,6 +39,7 @@ allow_override=ATTRS allow email content to override attributes specified by previous options ATTRS is a comma separated list of attributes + watchers=WATCHERS comma separated list of watcher emails Examples: # No project specified. Emails MUST contain the 'Project' keyword: @@ -58,6 +59,7 @@ options[:allow_override] = ENV['allow_override'] if ENV['allow_override'] options[:unknown_user] = ENV['unknown_user'] if ENV['unknown_user'] options[:no_permission_check] = ENV['no_permission_check'] if ENV['no_permission_check'] + options[:watchers] = ENV['watchers'] if ENV['watchers'] MailHandler.receive(STDIN.read, options) end @@ -91,6 +93,7 @@ allow_override=ATTRS allow email content to override attributes specified by previous options ATTRS is a comma separated list of attributes + watchers=WATCHERS comma separated list of watcher emails Processed emails control options: move_on_success=MAILBOX move emails that were successfully received @@ -129,6 +132,7 @@ options[:allow_override] = ENV['allow_override'] if ENV['allow_override'] options[:unknown_user] = ENV['unknown_user'] if ENV['unknown_user'] options[:no_permission_check] = ENV['no_permission_check'] if ENV['no_permission_check'] + options[:watchers] = ENV['watchers'] if ENV['watchers'] Redmine::IMAP.check(imap_options, options) end @@ -162,6 +166,7 @@ options[:allow_override] = ENV['allow_override'] if ENV['allow_override'] options[:unknown_user] = ENV['unknown_user'] if ENV['unknown_user'] options[:no_permission_check] = ENV['no_permission_check'] if ENV['no_permission_check'] + options[:watchers] = ENV['watchers'] if ENV['watchers'] Redmine::POP3.check(pop_options, options) end