aboutsummaryrefslogtreecommitdiff
path: root/server-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'server-core/src')
-rw-r--r--server-core/src/main/java/com/juick/server/MessagesQueries.java15
-rw-r--r--server-core/src/main/java/com/juick/util/MessageUtils.java24
2 files changed, 27 insertions, 12 deletions
diff --git a/server-core/src/main/java/com/juick/server/MessagesQueries.java b/server-core/src/main/java/com/juick/server/MessagesQueries.java
index b824feba..8a5c094c 100644
--- a/server-core/src/main/java/com/juick/server/MessagesQueries.java
+++ b/server-core/src/main/java/com/juick/server/MessagesQueries.java
@@ -21,6 +21,7 @@ import com.juick.Message;
import com.juick.Tag;
import com.juick.User;
import com.juick.server.helpers.PrivacyOpts;
+import com.juick.util.MessageUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
@@ -75,7 +76,7 @@ public class MessagesQueries {
}
msg.RepliesBy = rs.getString(19);
msg.setText(rs.getString(20));
- msg.setReplyQuote(formatQuote(rs.getString(21)));
+ msg.setReplyQuote(MessageUtils.formatQuote(rs.getString(21)));
return msg;
}
}
@@ -282,7 +283,7 @@ public class MessagesQueries {
msg.setText(rs.getString(6));
String quote = rs.getString(7);
if (!StringUtils.isEmpty(quote)) {
- msg.setReplyQuote(formatQuote(quote));
+ msg.setReplyQuote(MessageUtils.formatQuote(quote));
}
return msg;
}, mid, rid);
@@ -653,14 +654,4 @@ public class MessagesQueries {
}
return false;
}
-
- private static String formatQuote(String quote) {
- if (quote.length() > 50) {
- quote = ">" + quote.substring(0, 47).replace('\n', ' ') + "...\n";
- } else if (quote.length() > 0) {
- quote = ">" + quote.replace('\n', ' ') + "\n";
- }
- return quote;
- }
-
}
diff --git a/server-core/src/main/java/com/juick/util/MessageUtils.java b/server-core/src/main/java/com/juick/util/MessageUtils.java
new file mode 100644
index 00000000..1e8165c3
--- /dev/null
+++ b/server-core/src/main/java/com/juick/util/MessageUtils.java
@@ -0,0 +1,24 @@
+package com.juick.util;
+
+/**
+ * Created by aalexeev on 11/13/16.
+ */
+public class MessageUtils {
+ private MessageUtils() {
+ throw new IllegalStateException();
+ }
+
+ public static String formatQuote(final String quote) {
+ String result = quote;
+
+ if (quote != null) {
+ if (quote.length() > 50) {
+ result = ">" + quote.substring(0, 47).replace('\n', ' ') + "...\n";
+ } else if (!quote.isEmpty()) {
+ result = ">" + quote.replace('\n', ' ') + "\n";
+ }
+ }
+
+ return result;
+ }
+}