Skip to content

Commit

Permalink
remove use of reservationController.reSendReservationConfirmationEmai…
Browse files Browse the repository at this point in the history
…l in reservation api v2 controller #588
  • Loading branch information
syjer committed Jun 13, 2019
1 parent 53742b0 commit e390a9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.servlet.support.RequestContextUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -284,13 +285,18 @@ public ResponseEntity<ValidatedResponse<Boolean>> validateToOverview(@PathVariab

@PostMapping("/event/{eventName}/reservation/{reservationId}/re-send-email")
public ResponseEntity<Boolean> reSendReservationConfirmationEmail(@PathVariable("eventName") String eventName,
@PathVariable("reservationId") String reservationId, HttpServletRequest request) {
var res = reservationController.reSendReservationConfirmationEmail(eventName, reservationId, request);
if(res.endsWith("confirmation-email-sent=true")) {
return ResponseEntity.ok(true);
} else {
return ResponseEntity.ok(false);
}
@PathVariable("reservationId") String reservationId,
@RequestParam("lang") String lang) {

var res = eventRepository.findOptionalByShortName(eventName).map(event ->
ticketReservationManager.findById(reservationId).map(ticketReservation -> {
Locale locale = Locale.forLanguageTag(lang);
ticketReservationManager.sendConfirmationEmail(event, ticketReservation, locale);
return true;
}).orElse(false)
).orElse(false);

return ResponseEntity.ok(res);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ public void reservationFlowTest() throws Exception {
assertFalse(orderSummary.getNotYetPaid());


var confRes = reservationApiV2Controller.reSendReservationConfirmationEmail(event.getShortName(), reservationId, new MockHttpServletRequest());
var confRes = reservationApiV2Controller.reSendReservationConfirmationEmail(event.getShortName(), reservationId, "en");
assertEquals(HttpStatus.OK, confRes.getStatusCode());
assertTrue(confRes.getBody());

Expand Down

0 comments on commit e390a9f

Please sign in to comment.