summaryrefslogtreecommitdiffstats
path: root/extra/mail_handler/rdm-mailhandler.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-09 10:44:15 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-09 10:44:15 +0000
commit84abeac304a98f48a6801e9a05f213dee13656fd (patch)
tree3f41100f20db8ca6a2320ec6154bea6e3060b54f /extra/mail_handler/rdm-mailhandler.rb
parent3918374d5cf791fd3ae13d8ef888f327000d0aa5 (diff)
downloadredmine-84abeac304a98f48a6801e9a05f213dee13656fd.tar.gz
redmine-84abeac304a98f48a6801e9a05f213dee13656fd.zip
Improve rdm-mailhandler exit status (#4368).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3143 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'extra/mail_handler/rdm-mailhandler.rb')
-rw-r--r--extra/mail_handler/rdm-mailhandler.rb26
1 files changed, 22 insertions, 4 deletions
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))