Project

General

Profile

Feature #11498 » 0013-Added-no-account-notice-option-for-the-mail-handler-.patch

Alex Shulgin, 2012-07-24 14:26

View differences:

app/models/mail_handler.rb
42 42
    # Status overridable by default
43 43
    @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
44 44

  
45
    @@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
45
    @@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1')
46
    @@handler_options[:no_account_notice] = (@@handler_options[:no_account_notice].to_s == '1')
47

  
46 48
    super email
47 49
  end
48 50

  
......
87 89
        @user = create_user_from_email
88 90
        if @user
89 91
          logger.info "MailHandler: [#{@user.login}] account created"
90
          Mailer.deliver_account_information(@user, @user.password)
92
          unless @@handler_options[:no_account_notice]
93
            Mailer.deliver_account_information(@user, @user.password)
94
          end
91 95
        else
92 96
          logger.error "MailHandler: could not create account for [#{sender_email}]"
93 97
          return false
extra/mail_handler/rdm-mailhandler.rb
25 25
class RedmineMailHandler
26 26
  VERSION = '0.2'
27 27

  
28
  attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key, :no_check_certificate
28
  attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :no_account_notice, :url, :key, :no_check_certificate
29 29

  
30 30
  def initialize
31 31
    self.issue_attributes = {}
......
47 47
                                              "* create: create a user account") {|v| self.unknown_user = v}
48 48
      opts.on("--no-permission-check",        "disable permission checking when receiving",
49 49
                                              "the email") {self.no_permission_check = '1'}
50
      opts.on("--no-account-notice",          "disable new user account notification") {self.no_account_notice = '1'}
50 51
      opts.on("--key-file FILE",              "path to a file that contains the Redmine",
51 52
                                              "API key (use this option instead of --key",
52 53
                                              "if you don't the key to appear in the",
......
95 96
    data = { 'key' => key, 'email' => email,
96 97
                           'allow_override' => allow_override,
97 98
                           'unknown_user' => unknown_user,
98
                           'no_permission_check' => no_permission_check}
99
                           'no_permission_check' => no_permission_check,
100
                           'no_account_notice' => no_account_notice }
99 101
    issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value }
100 102

  
101 103
    debug "Posting to #{uri}..."
(1-1/3)