From 3dd5abdfd328a9dc95152639cf1773336502a23b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 26 Sep 2018 22:19:55 +0300 Subject: make SapeConfiguration conditional on sape token --- .../com/juick/server/www/controllers/MessagesWWW.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'juick-server/src/main/java/com/juick/server/www') diff --git a/juick-server/src/main/java/com/juick/server/www/controllers/MessagesWWW.java b/juick-server/src/main/java/com/juick/server/www/controllers/MessagesWWW.java index 130e1990..47c52cb9 100644 --- a/juick-server/src/main/java/com/juick/server/www/controllers/MessagesWWW.java +++ b/juick-server/src/main/java/com/juick/server/www/controllers/MessagesWWW.java @@ -45,6 +45,7 @@ import java.io.IOException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; /** @@ -60,7 +61,7 @@ public class MessagesWWW { @Inject private MessagesService messagesService; @Inject - private Sape sape; + private Optional sape; @Inject private PMQueriesService pmQueriesService; @Inject @@ -180,8 +181,8 @@ public class MessagesWWW { UriComponents builder = ServletUriComponentsBuilder.fromCurrentRequestUri().build(); String queryString = builder.getQuery(); String requestURI = builder.toUri().getPath(); - if (sape != null && visitor.isAnonymous() && queryString == null) { - String links = sape.getPageLinks(requestURI, sapeCookie).render(); + if (sape.isPresent() && visitor.isAnonymous() && queryString == null) { + String links = sape.get().getPageLinks(requestURI, sapeCookie).render(); model.addAttribute("links", links); } return "views/index"; @@ -299,8 +300,8 @@ public class MessagesWWW { UriComponents builder = ServletUriComponentsBuilder.fromCurrentRequestUri().build(); String queryString = builder.getQuery(); String requestURI = builder.toUri().getPath(); - if (sape != null && visitor.isAnonymous() && queryString == null) { - String links = sape.getPageLinks(requestURI, sapeCookie).render(); + if (sape.isPresent() && visitor.isAnonymous() && queryString == null) { + String links = sape.get().getPageLinks(requestURI, sapeCookie).render(); model.addAttribute("links", links); } return "views/blog"; @@ -439,8 +440,8 @@ public class MessagesWWW { UriComponents builder = ServletUriComponentsBuilder.fromCurrentRequestUri().build(); String queryString = builder.getQuery(); String requestURI = builder.toUri().getPath(); - if (sape != null && visitor.isAnonymous() && queryString == null) { - String links = sape.getPageLinks(requestURI, sapeCookie).render(); + if (sape.isPresent() && visitor.isAnonymous() && queryString == null) { + String links = sape.get().getPageLinks(requestURI, sapeCookie).render(); model.addAttribute("links", links); } return "views/index"; @@ -576,8 +577,8 @@ public class MessagesWWW { UriComponents builder = ServletUriComponentsBuilder.fromCurrentRequestUri().build(); String queryString = builder.getQuery(); String requestURI = builder.toUri().getPath(); - if (sape != null && visitor.isAnonymous() && queryString == null) { - String links = sape.getPageLinks(requestURI, sapeCookie).render(); + if (sape.isPresent() && visitor.isAnonymous() && queryString == null) { + String links = sape.get().getPageLinks(requestURI, sapeCookie).render(); model.addAttribute("links", links); } return "views/thread"; -- cgit v1.2.3