aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src/main/java/com/juick/components
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-03-02 17:24:39 +0300
committerGravatar Vitaly Takmazov2017-03-02 17:24:39 +0300
commitc2f4735877781313ef0d0960ac3c0403944a495c (patch)
tree6faf327903145713c9b91dc8b07f61fbf52430c1 /juick-xmpp/src/main/java/com/juick/components
parent434ea38eeb489f5c095ce55a16ef6dcca9489335 (diff)
juick-server: protocol refactoring
Diffstat (limited to 'juick-xmpp/src/main/java/com/juick/components')
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java12
1 files changed, 2 insertions, 10 deletions
diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java
index e6efd500..bab65141 100644
--- a/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java
+++ b/juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java
@@ -2,6 +2,7 @@ package com.juick.components.s2s;
import com.juick.User;
import com.juick.components.XMPPServer;
+import com.juick.formatters.PlainTextFormatter;
import org.apache.commons.lang3.StringUtils;
import org.ocpsoft.prettytime.PrettyTime;
import org.slf4j.Logger;
@@ -481,18 +482,9 @@ public class JuickBot implements StanzaListener, AutoCloseable {
}
String printMessages(List<Integer> mids, boolean crop) {
- int cropLength = 384;
return xmpp.messagesService.getMessages(mids).stream()
.sorted(Collections.reverseOrder())
- .map(m -> {
- String timeAgo = pt.format(m.getDate());
- String repliesCount = m.getReplies() == 1 ? "; 1 reply" : m.getReplies() == 0 ? ""
- : String.format("; %d replies", m.getReplies());
- String txt = crop ? m.getText().length() >= cropLength ?
- StringUtils.substring(m.getText(), 0, cropLength) + " [...]" : m.getText() : m.getText();
- return String.format("@%s:%s\n%s\n#%d (%s%s) http://juick.com/%d",
- m.getUser().getName(), m.getTagsString(), txt, m.getMid(), timeAgo, repliesCount, m.getMid());
- }).collect(Collectors.joining("\n\n"));
+ .map(PlainTextFormatter::formatPostSummary).collect(Collectors.joining("\n\n"));
}
void broadcastPresence(Presence.Type type) {