From a7825dede977692c0418119159090290e4f6ac34 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 26 Apr 2018 09:39:49 +0300 Subject: www: fix redirect after command --- .../java/com/juick/www/configuration/EmbeddedAPIConfig.java | 2 +- .../src/main/java/com/juick/www/controllers/NewMessage.java | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'juick-www') diff --git a/juick-www/src/main/java/com/juick/www/configuration/EmbeddedAPIConfig.java b/juick-www/src/main/java/com/juick/www/configuration/EmbeddedAPIConfig.java index 6ceb140b..0541ac25 100644 --- a/juick-www/src/main/java/com/juick/www/configuration/EmbeddedAPIConfig.java +++ b/juick-www/src/main/java/com/juick/www/configuration/EmbeddedAPIConfig.java @@ -14,6 +14,6 @@ public class EmbeddedAPIConfig { public ConfigurableApplicationContext apiContext() { return new SpringApplicationBuilder() .sources(PostConfig.class) - .run("--server.port=8081"); + .run("--server.port=8081", "--spring.jmx.enabled=false"); } } diff --git a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java index 83faf3a7..1b3db61d 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java +++ b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java @@ -34,7 +34,6 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.FormHttpMessageConverter; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.util.LinkedMultiValueMap; @@ -51,9 +50,6 @@ import javax.inject.Inject; import java.io.IOException; import java.net.URI; import java.net.URL; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; import java.util.stream.Collectors; /** @@ -219,7 +215,6 @@ public class NewMessage { @PostMapping("/post2") public String doPostMessage(@RequestParam(name = "body", required = false) String bodyParam, @RequestParam(required = false) String img, - @RequestParam(required = false) String referer, @RequestParam(required = false) MultipartFile attach) throws JsonProcessingException { com.juick.User visitor = UserUtils.getCurrentUser(); @@ -256,16 +251,13 @@ public class NewMessage { Message newMessage = result.getBody().getNewMessage().orElse(new Message()); if (newMessage.getMid() > 0) { logger.info("/post: {}", jsonMapper.writeValueAsString(result.getBody())); + return String.format("redirect:/%d", newMessage.getMid()); } else { logger.info("{} : {}", body, result.getBody().getText()); } - if (StringUtils.isBlank(referer) || referer.substring(0, 21).equals("http://juick.com/post") - || referer.substring(0, 22).equals("https://juick.com/post")) { - return String.format("redirect:/%d", newMessage.getMid()); - } } catch (HttpClientErrorException e) { logger.error("post error", e); } - return "redirect:" + referer; + return "redirect:/?show=my"; } } -- cgit v1.2.3