diff options
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) { |