From cd7e11563721d223b30f9b9edaa8295c2c97c6f7 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 13 Mar 2018 14:27:13 +0300 Subject: server: attachments in XMPP summary --- .../java/com/juick/formatters/PlainTextFormatter.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'juick-core/src/main/java/com') diff --git a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java index c7e79265..e41ab1f7 100644 --- a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java +++ b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java @@ -61,10 +61,19 @@ public class PlainTextFormatter { String timeAgo = pt.format(Date.from(m.getTimestamp())); String repliesCount = m.getReplies() == 1 ? "; 1 reply" : m.getReplies() == 0 ? "" : String.format("; %d replies", m.getReplies()); - String txt = StringUtils.defaultString(m.getText()).length() >= cropLength ? - StringUtils.substring(StringUtils.defaultString(m.getText()), 0, cropLength) + " [...]" : m.getText(); + StringBuilder sb = new StringBuilder(); + String txt = StringUtils.defaultString(m.getText()); + String attachmentUrl = MessageUtils.attachmentUrl(m); + if (StringUtils.isNotEmpty(attachmentUrl)) { + sb.append(attachmentUrl).append("\n"); + } + if (txt.length() >= cropLength) { + sb.append(StringUtils.substring(txt, 0, cropLength)).append(" [...]"); + } else { + sb.append(txt); + } return String.format("@%s:%s\n%s\n#%s (%s%s) %s", - m.getUser().getName(), m.getTagsString(), txt, formatPostNumber(m), timeAgo, repliesCount, formatUrl(m)); + m.getUser().getName(), m.getTagsString(), sb.toString(), formatPostNumber(m), timeAgo, repliesCount, formatUrl(m)); } public static String formatUrl(com.juick.Message jmsg) { -- cgit v1.2.3