aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'juick-core/src/main')
-rw-r--r--juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java15
-rw-r--r--juick-core/src/main/java/com/juick/util/MessageUtils.java17
2 files changed, 19 insertions, 13 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 5625fad6..c7e79265 100644
--- a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java
+++ b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java
@@ -50,19 +50,8 @@ public class PlainTextFormatter {
sb.append(StringUtils.defaultString(jmsg.getText()));
}
sb.append("\n");
- if (StringUtils.isNotEmpty(jmsg.getAttachmentType())) {
- // FIXME: attachment does not serialized to xml
- if (jmsg.getAttachment() == null) {
- if (jmsg.getRid() > 0) {
- sb.append(String.format("http://i.juick.com/photos-1024/%d-%d.%s", jmsg.getMid(),
- jmsg.getRid(), jmsg.getAttachmentType()));
- } else {
- sb.append(String.format("http://i.juick.com/photos-1024/%d.%s", jmsg.getMid(),
- jmsg.getAttachmentType()));
- }
- } else {
- sb.append(jmsg.getAttachment().getMedium().getUrl());
- }
+ if (!markdown && StringUtils.isNotEmpty(jmsg.getAttachmentType())) {
+ sb.append(MessageUtils.attachmentUrl(jmsg));
}
return sb.toString();
}
diff --git a/juick-core/src/main/java/com/juick/util/MessageUtils.java b/juick-core/src/main/java/com/juick/util/MessageUtils.java
index 97d55b09..f17737db 100644
--- a/juick-core/src/main/java/com/juick/util/MessageUtils.java
+++ b/juick-core/src/main/java/com/juick/util/MessageUtils.java
@@ -197,4 +197,21 @@ public class MessageUtils {
return s.replace("_", "\\_").replace("*", "\\*")
.replace("`", "\\`");
}
+ public static String attachmentUrl(final Message jmsg) {
+ if (StringUtils.isEmpty(jmsg.getAttachmentType())) {
+ return StringUtils.EMPTY;
+ }
+ // FIXME: attachment does not serialized to xml
+ if (jmsg.getAttachment() == null) {
+ if (jmsg.getRid() > 0) {
+ return String.format("http://i.juick.com/photos-1024/%d-%d.%s", jmsg.getMid(),
+ jmsg.getRid(), jmsg.getAttachmentType());
+ } else {
+ return String.format("http://i.juick.com/photos-1024/%d.%s", jmsg.getMid(),
+ jmsg.getAttachmentType());
+ }
+ } else {
+ return jmsg.getAttachment().getMedium().getUrl();
+ }
+ }
}