/*
  Third menu asks the user when the vote will close. Options are "instant vote", i.e., 5 minutes, versus "one day",
  versus "custom".
   */
  @RequestMapping(value = path + "time")
  @ResponseBody
  public Request votingTime(
      @RequestParam(value = phoneNumber) String inputNumber,
      @RequestParam(value = entityUidParam) String requestUid,
      @RequestParam(value = userInputParam) String issue,
      @RequestParam(value = interruptedFlag, required = false) boolean interrupted,
      @RequestParam(value = revisingFlag, required = false) boolean revising)
      throws URISyntaxException {

    User user = userManager.findByInputNumber(inputNumber, saveVoteMenu("time", requestUid));

    if (!interrupted && !revising) eventRequestBroker.updateName(user.getUid(), requestUid, issue);

    USSDMenu menu = new USSDMenu(getMessage(thisSection, "time", promptKey, user));

    String nextUrl =
        voteMenus + "confirm" + entityUidUrlSuffix + requestUid + "&field=standard&time=";
    String optionKey = voteKey + ".time." + optionsKey;

    menu.addMenuOption(nextUrl + "instant", getMessage(optionKey + "instant", user));
    menu.addMenuOption(nextUrl + "hour", getMessage(optionKey + "hour", user));
    menu.addMenuOption(nextUrl + "day", getMessage(optionKey + "day", user));
    menu.addMenuOption(nextUrl + "week", getMessage(optionKey + "week", user));
    menu.addMenuOption(
        voteMenus + "time_custom" + entityUidUrlSuffix + requestUid,
        getMessage(optionKey + "custom", user));

    return menuBuilder(menu);
  }
 private String[] adjustSubject(String requestUid, String userInput, User user) {
   String dateTime;
   eventRequestBroker.updateName(user.getUid(), requestUid, userInput);
   EventRequest vote = eventRequestBroker.load(requestUid);
   if (vote.getEventStartDateTime().isBefore(Instant.now().plus(7, ChronoUnit.MINUTES))) {
     // user is manipulating an "instant" vote so need to reset the counter, else may expire before
     // send
     eventRequestBroker.updateEventDateTime(
         user.getUid(), requestUid, LocalDateTime.now().plusMinutes(7L));
     dateTime = getMessage(thisSection, "confirm", "time.instant", user);
   } else {
     // need a quick way to do "at" in i18n
     dateTime = "at " + vote.getEventDateTimeAtSAST().format(dateTimeFormat);
   }
   return new String[] {userInput, dateTime};
 }