From a5f045a3780ef8530afa7493cf090771b8fdcfe1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 3 Apr 2018 17:55:46 +0300 Subject: refactoring: all messages are processed with XMPPConnection --- .../src/main/java/com/juick/server/api/Post.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'juick-server/src/main/java/com/juick/server/api') diff --git a/juick-server/src/main/java/com/juick/server/api/Post.java b/juick-server/src/main/java/com/juick/server/api/Post.java index 312df52d..7c8fb2ea 100644 --- a/juick-server/src/main/java/com/juick/server/api/Post.java +++ b/juick-server/src/main/java/com/juick/server/api/Post.java @@ -101,9 +101,9 @@ public class Post { } body = body.replace("\r", StringUtils.EMPTY); - String attachmentFName = HttpUtils.receiveMultiPartFile(attach, tmpDir); + URI attachmentFName = HttpUtils.receiveMultiPartFile(attach, tmpDir); - if (StringUtils.isBlank(attachmentFName) && img != null && img.length() > 10) { + if (StringUtils.isBlank(attachmentFName.toString()) && img != null && img.length() > 10) { try { URL imgUrl = new URL(img); attachmentFName = HttpUtils.downloadImage(imgUrl, tmpDir); @@ -112,11 +112,11 @@ public class Post { throw new HttpBadRequestException(); } } - xmppConnection.processMessage(visitor, body, attachmentFName); + xmppConnection.incomingMessageJuick(visitor, null, body, attachmentFName); } @PostMapping("/upload") public String doUploadFile(@RequestParam(required = true) MultipartFile attach) { - return HttpUtils.receiveMultiPartFile(attach, tmpDir); + return HttpUtils.receiveMultiPartFile(attach, tmpDir).toString(); } @RequestMapping(value = "/comment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @@ -158,9 +158,9 @@ public class Post { throw new HttpForbiddenException(); } - String attachmentFName = HttpUtils.receiveMultiPartFile(attach, tmpDir); + URI attachmentFName = HttpUtils.receiveMultiPartFile(attach, tmpDir); - if (StringUtils.isBlank(attachmentFName) && img != null && img.length() > 10) { + if (StringUtils.isBlank(attachmentFName.toString()) && img != null && img.length() > 10) { try { attachmentFName = HttpUtils.downloadImage(new URL(img), tmpDir); } catch (Exception e) { @@ -169,7 +169,7 @@ public class Post { } } - return xmppConnection.processMessage(visitor, body, attachmentFName); + return xmppConnection.incomingMessageJuick(visitor, null, body, attachmentFName); } Session session = Session.getDefaultInstance(new Properties()); @@ -231,7 +231,7 @@ public class Post { body[0] = rid > 0 ? String.format("#%d/%d %s", mid, rid, body[0]) : String.format("#%d %s", mid, body[0]); } - xmppConnection.processMessage(visitor, body[0], attachmentFName[0]); + xmppConnection.incomingMessageJuick(visitor, null, body[0], URI.create(String.format("juick://%s", attachmentFName[0]))); } else { logger.info("not registered: {}", from); } -- cgit v1.2.3