From c2f4735877781313ef0d0960ac3c0403944a495c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 2 Mar 2017 17:24:39 +0300 Subject: juick-server: protocol refactoring --- juick-xmpp/build.gradle | 1 - .../src/main/java/com/juick/components/s2s/JuickBot.java | 12 ++---------- 2 files changed, 2 insertions(+), 11 deletions(-) (limited to 'juick-xmpp') diff --git a/juick-xmpp/build.gradle b/juick-xmpp/build.gradle index 3cfbe86f..ceff6064 100644 --- a/juick-xmpp/build.gradle +++ b/juick-xmpp/build.gradle @@ -14,7 +14,6 @@ dependencies { compile 'javax.inject:javax.inject:1' compile 'org.apache.httpcomponents:httpclient:4.5.3' compile 'org.apache.commons:commons-dbcp2:2.1.1' - compile 'org.ocpsoft.prettytime:prettytime:3.2.7.Final' providedRuntime 'mysql:mysql-connector-java:5.1.40' } 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 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) { -- cgit v1.2.3