diff options
Diffstat (limited to 'extra/mail_handler/rdm-mailhandler.rb')
-rw-r--r-- | extra/mail_handler/rdm-mailhandler.rb | 26 |
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)) |