Project

General

Profile

Patch #8009 » watchers.patch

Max Khon, 2011-03-29 10:04

View differences:

app/models/mail_handler.rb Fri Mar 25 13:36:42 2011 +0600 → app/models/mail_handler.rb Tue Mar 29 13:36:24 2011 +0700
35 35
    @@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project)
36 36
    # Status overridable by default
37 37
    @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)    
38

  
39
    @@handler_options[:watchers] = @@handler_options[:watchers].split(',').collect(&:strip) if @@handler_options[:watchers].is_a?(String)
40
    @@handler_options[:watchers] ||= []
38 41
    
39 42
    @@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
40 43
    super email
......
210 213
  # appropriate permission
211 214
  def add_watchers(obj)
212 215
    if user.allowed_to?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project)
213
      addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase}
216
      addresses = ([email.to, email.cc] + @@handler_options[:watchers]).flatten.compact.uniq.collect {|a| a.strip.downcase}
214 217
      unless addresses.empty?
215 218
        watchers = User.active.find(:all, :conditions => ['LOWER(mail) IN (?)', addresses])
216 219
        watchers.each {|w| obj.add_watcher(w)}
lib/tasks/email.rake Fri Mar 25 13:36:42 2011 +0600 → lib/tasks/email.rake Tue Mar 29 13:36:24 2011 +0700
39 39
  allow_override=ATTRS     allow email content to override attributes
40 40
                           specified by previous options
41 41
                           ATTRS is a comma separated list of attributes
42
  watchers=WATCHERS        comma separated list of watcher emails
42 43

  
43 44
Examples:
44 45
  # No project specified. Emails MUST contain the 'Project' keyword:
......
58 59
      options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
59 60
      options[:unknown_user] = ENV['unknown_user'] if ENV['unknown_user']
60 61
      options[:no_permission_check] = ENV['no_permission_check'] if ENV['no_permission_check']
62
      options[:watchers] = ENV['watchers'] if ENV['watchers']
61 63
      
62 64
      MailHandler.receive(STDIN.read, options)
63 65
    end
......
91 93
  allow_override=ATTRS     allow email content to override attributes
92 94
                           specified by previous options
93 95
                           ATTRS is a comma separated list of attributes
96
  watchers=WATCHERS        comma separated list of watcher emails
94 97
                           
95 98
Processed emails control options:
96 99
  move_on_success=MAILBOX  move emails that were successfully received
......
129 132
      options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
130 133
      options[:unknown_user] = ENV['unknown_user'] if ENV['unknown_user']
131 134
      options[:no_permission_check] = ENV['no_permission_check'] if ENV['no_permission_check']
135
      options[:watchers] = ENV['watchers'] if ENV['watchers']
132 136

  
133 137
      Redmine::IMAP.check(imap_options, options)
134 138
    end
......
162 166
      options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
163 167
      options[:unknown_user] = ENV['unknown_user'] if ENV['unknown_user']
164 168
      options[:no_permission_check] = ENV['no_permission_check'] if ENV['no_permission_check']
169
      options[:watchers] = ENV['watchers'] if ENV['watchers']
165 170
      
166 171
      Redmine::POP3.check(pop_options, options)
167 172
    end
    (1-1/1)