From 7eb13edc1720b13924d7cbe715be67a535f0e02e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 30 Mar 2018 14:38:29 +0300 Subject: www: drop unused method --- .../java/com/juick/www/controllers/NewMessage.java | 101 --------------------- 1 file changed, 101 deletions(-) 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 7c378930..f8a11d82 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 @@ -100,107 +100,6 @@ public class NewMessage { return "views/post"; } - @PostMapping("/post") - public String postResult(@RequestParam(required = false) String img, - @RequestParam(required = false, defaultValue = StringUtils.EMPTY) String body, - @RequestParam(required = false, name = "tags") String tagsStr, - @RequestParam(required = false) MultipartFile attach, ModelMap model) throws IOException { - com.juick.User visitor = UserUtils.getCurrentUser(); - if (visitor.getUid() == 0 || visitor.isBanned()) { - throw new HttpForbiddenException(); - } - if ((StringUtils.isEmpty(body) || body.length() > 4096) && StringUtils.isEmpty(img) && attach == null) { - throw new HttpBadRequestException(); - } - body = body.replace("\r", StringUtils.EMPTY); - - List tags = webApp.parseTags(tagsStr); - - String attachmentFName = HttpUtils.receiveMultiPartFile(attach, tmpDir); - - if (StringUtils.isBlank(attachmentFName) && 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(); - } - } - - String attachmentType = StringUtils.isNotEmpty(attachmentFName) ? attachmentFName.substring(attachmentFName.length() - 3) : null; - int mid = messagesService.createMessage(visitor.getUid(), body, attachmentType, tags); - subscriptionService.subscribeMessage(mid, visitor.getUid()); - - Message xmsg = new Message(); - xmsg.setFrom(Jid.of("juick@juick.com")); - xmsg.setType(Message.Type.CHAT); - xmsg.setThread("juick-" + mid); - com.juick.Message jmsg = messagesService.getMessage(mid); - xmsg.addExtension(jmsg); - xmsg.addExtension(new Nickname("@" + jmsg.getUser().getName())); - - if (StringUtils.isNotEmpty(attachmentFName)) { - String fname = mid + "." + attachmentType; - String attachmentURL = "http://i.juick.com/photos-1024/" + fname; - - ImageUtils.saveImageWithPreviews(attachmentFName, fname, tmpDir, imgDir); - - body = attachmentURL + "\n" + body; - try { - xmsg.addExtension(new OobX(new URI(attachmentURL))); - } catch (URISyntaxException e) { - logger.warn("invalid uri: {} exception {}", attachmentURL, e); - } - } - if (xmpp.isConnected()) { - - xmsg.setBody("@" + jmsg.getUser().getName() + ":" + MessageUtils.getTagsString(jmsg) + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid); - - xmsg.setTo(Jid.of("juick@s2s.juick.com")); - xmpp.send(xmsg); - - xmsg.setTo(Jid.of("jubo@nologin.ru")); - xmpp.send(xmsg); - } else { - logger.warn("XMPP unavailable"); - } - - // - - model.addAttribute("title", "Сообщение опубликовано"); - model.addAttribute("visitor", visitor); - model.addAttribute("user", visitor); - - String hashtags = StringUtils.EMPTY; - String tagscomma = StringUtils.EMPTY; - for (int i = 0; i < jmsg.getTags().size(); i++) { - if (i > 0) { - hashtags += " "; - tagscomma += ","; - } - hashtags += "#" + jmsg.getTags().get(i); - tagscomma += jmsg.getTags().get(i); - } - - model.addAttribute("url", "http://juick.com/" + mid); - - if (!crosspostService.getTwitterToken(visitor.getUid()).isPresent()) { - String sharetwi = hashtags + " " + body; - if (sharetwi.length() > 115) { - sharetwi = sharetwi.substring(0, 114) + "…"; - } - sharetwi += " http://juick.com/" + mid; - model.addAttribute("sharetwi", sharetwi); - } - if (!crosspostService.getFacebookTokens(visitor.getUid()).isPresent()) { - model.addAttribute("facebook", 1); - } - model.addAttribute("tags", tagService.getUserTagStats(visitor.getUid()).stream() - .sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).map(t -> t.getTag().getName()).collect(Collectors.toList())); - return "views/post_success"; - } - @PostMapping("/comment") public String doPostComment( @RequestParam Integer mid, -- cgit v1.2.3