aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main')
-rw-r--r--juick-server/src/main/java/com/juick/server/configuration/SapeConfiguration.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/www/controllers/MessagesWWW.java19
2 files changed, 13 insertions, 10 deletions
diff --git a/juick-server/src/main/java/com/juick/server/configuration/SapeConfiguration.java b/juick-server/src/main/java/com/juick/server/configuration/SapeConfiguration.java
index 53b29415..9727fbb1 100644
--- a/juick-server/src/main/java/com/juick/server/configuration/SapeConfiguration.java
+++ b/juick-server/src/main/java/com/juick/server/configuration/SapeConfiguration.java
@@ -18,6 +18,7 @@
package com.juick.server.configuration;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.sape.Sape;
@@ -26,8 +27,9 @@ import ru.sape.Sape;
* Created by vitalyster on 29.03.2017.
*/
@Configuration
+@ConditionalOnProperty("sape_user")
public class SapeConfiguration {
- @Value("${sape_user:secret}")
+ @Value("${sape_user:}")
private String token;
@Bean
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";