Ejemplo n.º 1
0
 @RequestMapping(value = "/{templateName}/{cmsName}", method = POST)
 public String sendEmail(
     DownloadRequest downloadRequest,
     @PathVariable String templateName,
     @PathVariable String cmsName) {
   downloadRequest.setTemplateName(templateName);
   downloadRequest.setCms(cmsName);
   downloadRequest.setCreated(LocalDateTime.now());
   logger.info("New download request: {}", downloadRequest);
   downloadRequest = downloadRequestRepository.save(downloadRequest);
   long timestamp = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC);
   String hash =
       downloadRequestParamsHasher.getHash(
           Template.valueOf(templateName).getDownloadName(),
           Cms.valueOf(cmsName).getNamePl(),
           timestamp);
   HtmlEmailMessage htmlEmailMessage =
       new HtmlEmailMessage(
           "*****@*****.**",
           downloadRequest.getAdministrativeEmail(),
           "Szablon CMS ze strony PWD",
           getEmailMessageTemplate(),
           getEmailMessageModelMap(
               templateName,
               Template.valueOf(templateName).getDownloadName(),
               Cms.valueOf(cmsName).getNamePl(),
               hash,
               timestamp));
   if (mailgunClient.sendEmail(htmlEmailMessage)) {
     return "email_download";
   }
   return "error";
 }
Ejemplo n.º 2
0
 @RequestMapping(value = "/{templateName}/{cmsName}", method = RequestMethod.GET)
 public String showTemplateDownloadForm(
     @PathVariable String templateName, @PathVariable String cmsName, Model model) {
   model.addAttribute("template", Template.valueOf(templateName));
   model.addAttribute("cms", Cms.valueOf(cmsName));
   return "downloadForm";
 }