| Line 408... |
Line 408... |
| 408 |
|
408 |
|
| 409 |
@RequestMapping(value = "/loiAcceptanceOtp", method = RequestMethod.POST)
|
409 |
@RequestMapping(value = "/loiAcceptanceOtp", method = RequestMethod.POST)
|
| 410 |
public String sentLoiAcceptanceOtp(@RequestParam int loiId, Model model) throws Exception {
|
410 |
public String sentLoiAcceptanceOtp(@RequestParam int loiId, Model model) throws Exception {
|
| 411 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
411 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
| 412 |
String mobile = String.valueOf(loiForm.getMobile());
|
412 |
String mobile = String.valueOf(loiForm.getMobile());
|
| - |
|
413 |
Map<String, Object> response = new HashMap<>();
|
| - |
|
414 |
|
| - |
|
415 |
OTPResponse otpResponse;
|
| - |
|
416 |
try {
|
| 413 |
OTPResponse otpResponse = otpProcessor.generateOtp(mobile, OtpType.LOI_ACCEPTANCE);
|
417 |
otpResponse = otpProcessor.generateOtp(mobile, OtpType.LOI_ACCEPTANCE);
|
| - |
|
418 |
} catch (Exception e) {
|
| 414 |
String message = "OTP send on your register mobile and EmailId - ";
|
419 |
// The dispatch itself blew up (gateway error, duplicate loi_form on this mobile, ...). Never
|
| - |
|
420 |
// report this as a send - the panel used to show "OTP Sent Successfully!" for exactly this case.
|
| 415 |
LOGGER.info("OTPResponse Message - " + otpResponse.getMessage());
|
421 |
LOGGER.error("LOI acceptance OTP dispatch failed for loiId " + loiId + ", mobile " + mobile, e);
|
| - |
|
422 |
response.put("status", false);
|
| 416 |
if (otpResponse.isResult()) {
|
423 |
response.put("sent", false);
|
| - |
|
424 |
response.put("message", "OTP could not be sent due to a system error. Please report to tech support.");
|
| 417 |
model.addAttribute("response1", mvcResponseSender.createResponseString(message + mobile + " and " + loiForm.getEmail()));
|
425 |
model.addAttribute("response1", mvcResponseSender.createResponseString(response));
|
| 418 |
return "response";
|
426 |
return "response";
|
| - |
|
427 |
}
|
| - |
|
428 |
|
| - |
|
429 |
LOGGER.info("OTPResponse for loiId " + loiId + " - result=" + otpResponse.isResult()
|
| - |
|
430 |
+ ", sent=" + otpResponse.isSent() + ", message=" + otpResponse.getMessage());
|
| - |
|
431 |
|
| - |
|
432 |
response.put("status", otpResponse.isResult());
|
| - |
|
433 |
response.put("sent", otpResponse.isSent());
|
| - |
|
434 |
if (otpResponse.isResult() && otpResponse.isSent()) {
|
| - |
|
435 |
response.put("message", "OTP sent on registered mobile and EmailId - " + mobile + " and " + loiForm.getEmail());
|
| 419 |
} else {
|
436 |
} else {
|
| - |
|
437 |
// Accepted-but-not-dispatched (resend throttle) and outright rejections (daily cap) both land
|
| 420 |
model.addAttribute("response1", mvcResponseSender.createResponseString("Something went wrong.."));
|
438 |
// here. Pass the processor's own reason through instead of a generic "Something went wrong..".
|
| 421 |
return "response";
|
439 |
response.put("message", otpResponse.getMessage());
|
| 422 |
}
|
440 |
}
|
| - |
|
441 |
model.addAttribute("response1", mvcResponseSender.createResponseString(response));
|
| - |
|
442 |
return "response";
|
| 423 |
}
|
443 |
}
|
| 424 |
|
444 |
|
| 425 |
@RequestMapping(value = "/validateLoiOtp", method = RequestMethod.PUT)
|
445 |
@RequestMapping(value = "/validateLoiOtp", method = RequestMethod.PUT)
|
| 426 |
public ResponseEntity<?> validateLoiAcceptanceOtp(HttpServletRequest request, @RequestParam int loiId, @RequestParam String provideOtp, Model model) throws Exception {
|
446 |
public ResponseEntity<?> validateLoiAcceptanceOtp(HttpServletRequest request, @RequestParam int loiId, @RequestParam String provideOtp, Model model) throws Exception {
|
| 427 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|
447 |
LoiForm loiForm = loiFormRepository.selectById(loiId);
|