Mercurial > hg > soundsoftware-site
diff extra/mail_handler/rdm-mailhandler.rb @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | 3e4c3460b6ca |
children |
line wrap: on
line diff
--- a/extra/mail_handler/rdm-mailhandler.rb Fri Jun 14 09:01:12 2013 +0100 +++ b/extra/mail_handler/rdm-mailhandler.rb Fri Jun 14 09:02:21 2013 +0100 @@ -23,9 +23,10 @@ end class RedmineMailHandler - VERSION = '0.2.1' + VERSION = '0.2.3' - attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key, :no_check_certificate + attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check, + :url, :key, :no_check_certificate, :no_account_notice, :no_notification def initialize self.issue_attributes = {} @@ -40,11 +41,6 @@ opts.on("-k", "--key KEY", "Redmine API key") {|v| self.key = v} opts.separator("") opts.separator("General options:") - opts.on("--unknown-user ACTION", "how to handle emails from an unknown user", - "ACTION can be one of the following values:", - "* ignore: email is ignored (default)", - "* accept: accept as anonymous user", - "* create: create a user account") {|v| self.unknown_user = v} opts.on("--no-permission-check", "disable permission checking when receiving", "the email") {self.no_permission_check = '1'} opts.on("--key-file FILE", "path to a file that contains the Redmine", @@ -56,6 +52,19 @@ opts.on("-v", "--verbose", "show extra information") {self.verbose = true} opts.on("-V", "--version", "show version information and exit") {puts VERSION; exit} opts.separator("") + opts.separator("User creation options:") + opts.on("--unknown-user ACTION", "how to handle emails from an unknown user", + "ACTION can be one of the following values:", + "* ignore: email is ignored (default)", + "* accept: accept as anonymous user", + "* create: create a user account") {|v| self.unknown_user = v} + opts.on("--default-group GROUP", "add created user to GROUP (none by default)", + "GROUP can be a comma separated list of groups") { |v| self.default_group = v} + opts.on("--no-account-notice", "don't send account information to the newly", + "created user") { |v| self.no_account_notice = '1'} + opts.on("--no-notification", "disable email notifications for the created", + "user") { |v| self.no_notification = '1'} + opts.separator("") opts.separator("Issue attributes control options:") opts.on("-p", "--project PROJECT", "identifier of the target project") {|v| self.issue_attributes['project'] = v} opts.on("-s", "--status STATUS", "name of the target status") {|v| self.issue_attributes['status'] = v} @@ -95,11 +104,19 @@ data = { 'key' => key, 'email' => email, 'allow_override' => allow_override, 'unknown_user' => unknown_user, + 'default_group' => default_group, + 'no_account_notice' => no_account_notice, + 'no_notification' => no_notification, 'no_permission_check' => no_permission_check} issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value } debug "Posting to #{uri}..." - response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate) + begin + response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate) + rescue SystemCallError => e # connection refused, etc. + warn "An error occured while contacting your Redmine server: #{e.message}" + return 75 # temporary failure + end debug "Response received: #{response.code}" case response.code.to_i