diff options
Diffstat (limited to 'juick-xmpp/src/main/java/com/juick')
-rw-r--r-- | juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java | 12 |
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) { |