rdm-mailhandler_exitcode.patch

Peter Fern, 2009-12-09 09:52

Download (1.55 KB)

View differences:

extra/mail_handler/rdm-mailhandler.rb
125 125
    response = Net::HTTPS.post_form(URI.parse(uri), data)
126 126
    debug "Response received: #{response.code}"
127 127
    
128
    puts "Request was denied by your Redmine server. " + 
129
         "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'
130
    response.code == '201' ? 0 : 1
128
    case response.code.to_i
129
      when 443
130
        warn "Request was denied by your Redmine server. " + 
131
             "Please, make sure that 'WS for incoming emails' is enabled in application settings and that you provided the correct API key."
132
        return 77
133
      when 422
134
        warn "Request was denied by your Redmine server. " +
135
             "Likely you have sent an email from an invalid email address."
136
        return 77
137
      when 400..499
138
        warn "Request was denied by your Redmine server (#{response.code})."
139
        return 77
140
      when 500..599
141
        warn "Failed to contact your Redmine server (#{response.code})."
142
        return 75
143
      when 201
144
        debug "Proccessed successfully"
145
        return 0
146
      else
147
        return 1
148
    end
131 149
  end
132 150
  
133 151
  private
......
138 156
end
139 157

  
140 158
handler = RedmineMailHandler.new
141
handler.submit(STDIN.read)
159
exit(handler.submit(STDIN.read))