diff options
author | 2018-04-03 17:55:46 +0300 | |
---|---|---|
committer | 2018-04-03 17:55:54 +0300 | |
commit | a5f045a3780ef8530afa7493cf090771b8fdcfe1 (patch) | |
tree | 56e4cbc6949dc9bd39672ccf379324338f0eef76 /juick-server/src/main/java/com/juick/server/api/Post.java | |
parent | c53675e5eb19a1a05ae5edcd0322075d51628b96 (diff) |
refactoring: all messages are processed with XMPPConnection
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/api/Post.java')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/Post.java | 16 |
1 files changed, 8 insertions, 8 deletions
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); } |