From f010d75872763547ecbe621ae3e8eb967950453f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 13 Mar 2018 15:18:03 +0300 Subject: core: cleanup unused message properties --- .../java/com/juick/www/controllers/Messages.java | 32 +++------------------- .../java/com/juick/www/controllers/NewMessage.java | 3 +- 2 files changed, 6 insertions(+), 29 deletions(-) (limited to 'juick-www/src/main/java/com/juick') diff --git a/juick-www/src/main/java/com/juick/www/controllers/Messages.java b/juick-www/src/main/java/com/juick/www/controllers/Messages.java index 11dafda36..ea66e711a 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/Messages.java +++ b/juick-www/src/main/java/com/juick/www/controllers/Messages.java @@ -16,6 +16,7 @@ */ package com.juick.www.controllers; +import com.juick.Message; import com.juick.Tag; import com.juick.formatters.PlainTextFormatter; import com.juick.server.util.HttpForbiddenException; @@ -23,6 +24,7 @@ import com.juick.server.util.HttpNotFoundException; import com.juick.server.util.UserUtils; import com.juick.server.util.WebUtils; import com.juick.service.*; +import com.juick.util.MessageUtils; import com.juick.www.Utils; import org.apache.commons.codec.CharEncoding; import org.apache.commons.lang3.StringUtils; @@ -533,7 +535,7 @@ public class Messages { } model.addAttribute("msg", msg); - String title = msg.getUser().getName() + ": " + msg.getTagsString(); + String title = msg.getUser().getName() + ": " + MessageUtils.getTagsString(msg); model.addAttribute("title", title); model.addAttribute("visitor", visitor); @@ -576,26 +578,11 @@ public class Messages { List replies = messagesService.getReplies(msg.getMid()); List blUIDs = new ArrayList<>(); - for (int i = 0; i < replies.size(); i++) { - com.juick.Message reply = replies.get(i); + for (Message reply : replies) { if (reply.getUser().getUid() != msg.getUser().getUid() && !blUIDs.contains(reply.getUser().getUid())) { blUIDs.add(reply.getUser().getUid()); } - if (reply.getReplyto() > 0) { - boolean added = false; - for (int n = 0; n < replies.size(); n++) { - if (replies.get(n).getRid() == reply.getReplyto()) { - replies.get(n).childs.add(reply); - added = true; - break; - } - } - if (!added) { - reply.setReplyto(0); - } - } - reply.VisitorCanComment = visitor.getUid() > 0; if (visitor.getUid() > 0) { boolean isMsgAuthor = visitor.getUid() == msg.getUser().getUid(); @@ -604,18 +591,7 @@ public class Messages { && msg.VisitorCanComment && (isReplyAuthor || !userService.isInBLAny(visitor.getUid(), reply.getUser().getUid()))); } } - - boolean foldable = false; - if (replies.size() > 10) { - for (int i = 0; i < replies.size() - 1; i++) { - if (replies.get(i).getChildsCount() > 1) { - foldable = true; - break; - } - } - } model.addAttribute("replies", replies); - model.addAttribute("foldable", foldable); model.addAttribute("showAdv", visitor.getUid() == 0); UriComponents builder = ServletUriComponentsBuilder.fromCurrentRequestUri().build(); String queryString = builder.getQuery(); 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 4d3b43518..6d7de920c 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 @@ -22,6 +22,7 @@ import com.juick.User; import com.juick.server.helpers.AnonymousUser; import com.juick.server.util.*; import com.juick.service.*; +import com.juick.util.MessageUtils; import com.juick.www.WebApp; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringEscapeUtils; @@ -148,7 +149,7 @@ public class NewMessage { } if (webApp.getXmpp() != null) { - xmsg.setBody("@" + jmsg.getUser().getName() + ":" + jmsg.getTagsString() + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid); + 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")); webApp.getXmpp().send(xmsg); -- cgit v1.2.3