diff options
author | 2018-03-13 14:27:13 +0300 | |
---|---|---|
committer | 2018-03-13 14:27:13 +0300 | |
commit | cd7e11563721d223b30f9b9edaa8295c2c97c6f7 (patch) | |
tree | 8ec43d980452dca27c2d5d37d9adcc796ad4a432 /juick-core/src/main/java | |
parent | 9852c44e52832a8fb8223214e5bbf6866312c60d (diff) |
server: attachments in XMPP summary
Diffstat (limited to 'juick-core/src/main/java')
-rw-r--r-- | juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java | 15 |
1 files changed, 12 insertions, 3 deletions
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) { |