aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp
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
parent434ea38eeb489f5c095ce55a16ef6dcca9489335 (diff)
juick-server: protocol refactoring
Diffstat (limited to 'juick-xmpp')
-rw-r--r--juick-xmpp/build.gradle1
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/JuickBot.java12
2 files changed, 2 insertions, 11 deletions
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<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) {