Improve rdm-mailhandler exit status (#4368).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3143 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3918374d5c
commit
84abeac304
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue