From: Jean-Philippe Lang Date: Wed, 9 Dec 2009 10:44:15 +0000 (+0000) Subject: Improve rdm-mailhandler exit status (#4368). X-Git-Tag: 0.9.0~119 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=84abeac304a98f48a6801e9a05f213dee13656fd;p=redmine.git Improve rdm-mailhandler exit status (#4368). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3143 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/extra/mail_handler/rdm-mailhandler.rb b/extra/mail_handler/rdm-mailhandler.rb index db3c8e658..91bb771b9 100644 --- a/extra/mail_handler/rdm-mailhandler.rb +++ b/extra/mail_handler/rdm-mailhandler.rb @@ -125,9 +125,27 @@ class RedmineMailHandler response = Net::HTTPS.post_form(URI.parse(uri), data) debug "Response received: #{response.code}" - puts "Request was denied by your Redmine server. " + - "Please, make sure that 'WS for incoming emails' is enabled in application settings and that you provided the correct API key." if response.code == '403' - response.code == '201' ? 0 : 1 + case response.code.to_i + when 403 + warn "Request was denied by your Redmine server. " + + "Make sure that 'WS for incoming emails' is enabled in application settings and that you provided the correct API key." + return 77 + when 422 + warn "Request was denied by your Redmine server. " + + "Possible reasons: email is sent from an invalid email address or is missing some information." + return 77 + when 400..499 + warn "Request was denied by your Redmine server (#{response.code})." + return 77 + when 500..599 + warn "Failed to contact your Redmine server (#{response.code})." + return 75 + when 201 + debug "Proccessed successfully" + return 0 + else + return 1 + end end private @@ -138,4 +156,4 @@ class RedmineMailHandler end handler = RedmineMailHandler.new -handler.submit(STDIN.read) +exit(handler.submit(STDIN.read))