aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-13 15:18:03 +0300
committerGravatar Vitaly Takmazov2018-03-13 15:18:03 +0300
commitf010d75872763547ecbe621ae3e8eb967950453f (patch)
tree385d3f0a960e10c7fd054fcb71ea280142495d31 /juick-www/src/main/java/com
parentcd7e11563721d223b30f9b9edaa8295c2c97c6f7 (diff)
core: cleanup unused message properties
Diffstat (limited to 'juick-www/src/main/java/com')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/Messages.java32
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/NewMessage.java3
-rw-r--r--juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java1
-rw-r--r--juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatRepliesFilter.java48
4 files changed, 6 insertions, 78 deletions
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 11dafda3..ea66e711 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<com.juick.Message> replies = messagesService.getReplies(msg.getMid());
List<Integer> 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 4d3b4351..6d7de920 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);
diff --git a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java
index c8244df4..9189c2be 100644
--- a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java
+++ b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java
@@ -30,7 +30,6 @@ public class FormatterExtension extends AbstractExtension {
public Map<String, Filter> getFilters() {
Map<String, Filter> filters = new HashMap<>();
filters.put("formatMessage", new FormatMessageFilter());
- filters.put("formatReplies", new FormatRepliesFilter());
filters.put("prettyTime", new PrettyTimeFilter());
filters.put("timestamp", new TimestampFilter());
filters.put("tagsList", new TagsListFilter());
diff --git a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatRepliesFilter.java b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatRepliesFilter.java
deleted file mode 100644
index f375ecdb..00000000
--- a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatRepliesFilter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008-2017, Juick
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.mitchellbosecke.pebble.extension.filters;
-
-import com.juick.Message;
-import com.mitchellbosecke.pebble.extension.Filter;
-
-import java.util.List;
-import java.util.Map;
-
-public class FormatRepliesFilter implements Filter {
- @Override
- public Object apply(Object input, Map<String, Object> args) {
- if (input instanceof Message) {
- int replies = ((Message)input).getChildsCount();
- int ld = replies % 10;
- int lh = replies % 100;
- if ((lh < 10 || lh > 20) && ld == 1) {
- return replies + " ответ";
- } else if ((lh < 10 || lh > 20) && ld > 1 && ld < 5) {
- return replies + " ответа";
- } else {
- return replies + " ответов";
- }
- }
- throw new IllegalArgumentException("invalid input");
- }
-
- @Override
- public List<String> getArgumentNames() {
- return null;
- }
-}