diff options
author | Vitaly Takmazov | 2018-09-26 22:19:55 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-09-26 22:19:55 +0300 |
commit | 3dd5abdfd328a9dc95152639cf1773336502a23b (patch) | |
tree | 50a2df323f83fa14971e2014574d6fd0d6d595a9 /juick-server/src/main/java/com/juick/server/www | |
parent | 80ad470b209eb11dd0225bb8c4d053787d6e4b4a (diff) |
make SapeConfiguration conditional on sape token
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/www')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/www/controllers/MessagesWWW.java | 19 |
1 files changed, 10 insertions, 9 deletions
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> 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"; |