aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-27 22:47:07 +0300
committerGravatar Vitaly Takmazov2018-09-27 22:47:07 +0300
commited9f1256cf2bfd93b749b6e2ef22114d7fcd89bc (patch)
treeed846bd7a981d763e659371088e19313c3b081a4 /juick-server/src/main/java/com/juick/server/www
parent5f4af8dbe4c431218c4bd186a75f50c23b8e5df0 (diff)
drop unused post mappings
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/NewMessage.java116
1 files changed, 0 insertions, 116 deletions
diff --git a/juick-server/src/main/java/com/juick/server/www/controllers/NewMessage.java b/juick-server/src/main/java/com/juick/server/www/controllers/NewMessage.java
index c476e5c2..6fb13009 100644
--- a/juick-server/src/main/java/com/juick/server/www/controllers/NewMessage.java
+++ b/juick-server/src/main/java/com/juick/server/www/controllers/NewMessage.java
@@ -105,74 +105,6 @@ public class NewMessage {
.sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).map(t -> t.getTag().getName()).collect(Collectors.toList()));
return "views/post";
}
-
- @PostMapping("/comment")
- public String doPostComment(
- @RequestParam Integer mid,
- @RequestParam(required = false, defaultValue = "0") Integer rid,
- @RequestParam(required = false, defaultValue = StringUtils.EMPTY) String body,
- @RequestParam(required = false, defaultValue = StringUtils.EMPTY) String img,
- @RequestParam(required = false) MultipartFile attach) throws IOException {
- com.juick.User visitor = UserUtils.getCurrentUser();
- if (visitor.isAnonymous() || visitor.isBanned()) {
- throw new HttpForbiddenException();
- }
- com.juick.Message msg = messagesService.getMessage(mid);
- if (msg == null) {
- throw new HttpNotFoundException();
- }
-
- com.juick.Message reply = null;
- if (rid > 0) {
- reply = messagesService.getReply(mid, rid);
- if (reply == null) {
- throw new HttpNotFoundException();
- }
- }
-
- if ((StringUtils.isEmpty(body) || body.length() > 4096) && StringUtils.isEmpty(img) && attach == null) {
- throw new HttpBadRequestException();
- }
- body = body.replace("\r", StringUtils.EMPTY);
-
- if ((msg.ReadOnly && msg.getUser().getUid() != visitor.getUid())
- || userService.isInBLAny(msg.getUser().getUid(), visitor.getUid())
- || (reply != null && userService.isInBLAny(reply.getUser().getUid(), visitor.getUid()))) {
- throw new HttpForbiddenException();
- }
-
- URI attachmentFName = HttpUtils.receiveMultiPartFile(attach, tmpDir);
-
- if (StringUtils.isBlank(attachmentFName.toString()) && img != null && img.length() > 10) {
- try {
- URL imgUrl = new URL(img);
- attachmentFName = HttpUtils.downloadImage(imgUrl, tmpDir);
- } catch (Exception e) {
- logger.error("DOWNLOAD ERROR", e);
- throw new HttpBadRequestException();
- }
- }
-
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
- MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
- HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers);
-
-
- params.add("body", rid == 0 ? String.format("#%d %s", mid, body) : String.format("#%d/%d %s", mid, rid, body));
- params.add("hash", userService.getHashByUID(visitor.getUid()));
- if (StringUtils.isNotEmpty(attachmentFName.toString())) {
- params.add("img", attachmentFName.toASCIIString());
- }
- URI postUri = UriComponentsBuilder.fromUriString(apiUrl).path("/api/post").build().toUri();
- ResponseEntity<CommandResult> result = rest.postForEntity(
- postUri,
- request, CommandResult.class);
- logger.info("/comment: {}", jsonMapper.writeValueAsString(result.getBody()));
- boolean wasReply = result.getBody().getNewMessage().isPresent();
- return wasReply ? "redirect:/" + msg.getUser().getName() + "/" + mid + "#" + result.getBody().getNewMessage().get().getRid() : "redirect:/" + msg.getUser().getName() + "/" + mid;
- }
-
@PostMapping("/pm/send")
public String doPostPM(@RequestParam(name = "uname", required = false) String unameParam,
@RequestParam String body) throws IOException {
@@ -212,52 +144,4 @@ public class NewMessage {
return "redirect:/pm/sent";
}
- @PostMapping("/post2")
- public String doPostMessage(@RequestParam(name = "body", required = false) String bodyParam,
- @RequestParam(required = false) String img,
- @RequestParam(required = false) MultipartFile attach) throws IOException {
-
- com.juick.User visitor = UserUtils.getCurrentUser();
- if (visitor.isAnonymous() || visitor.isBanned()) {
- throw new HttpForbiddenException();
- }
- String body = StringUtils.isNotEmpty(bodyParam) ? bodyParam.replace("\r", StringUtils.EMPTY) : StringUtils.EMPTY;
-
- URI attachmentFName = HttpUtils.receiveMultiPartFile(attach, tmpDir);
-
- if (StringUtils.isBlank(attachmentFName.toString()) && StringUtils.isNotBlank(img)) {
- try {
- URL imgUrl = new URL(img);
- attachmentFName = HttpUtils.downloadImage(imgUrl, tmpDir);
- } catch (Exception e) {
- logger.error("DOWNLOAD ERROR", e);
- throw new HttpBadRequestException();
- }
- }
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
- MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
- HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers);
-
- params.add("body", body);
- params.add("hash", userService.getHashByUID(visitor.getUid()));
- if (StringUtils.isNotEmpty(attachmentFName.toString())) {
- params.add("img", attachmentFName.toASCIIString());
- }
- URI postUri = UriComponentsBuilder.fromUriString(apiUrl).path("/api/post").build().toUri();
- try {
- ResponseEntity<CommandResult> result = rest.postForEntity(postUri,
- request, CommandResult.class);
- 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());
- }
- } catch (HttpClientErrorException e) {
- logger.error("post error", e);
- }
- return "redirect:/?show=my";
- }
}