aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-02-21 23:52:11 +0300
committerGravatar Vitaly Takmazov2018-02-21 23:52:11 +0300
commit2a5753cb32dd184d66ee28d38881c9135f8526c4 (patch)
treeee1e0e13d2cf0958c55f75344d04b7070a2e73ca /juick-core/src/main/java/com/juick
parent043e6493429bfc0d5699db9dacba4f74ac73fdc2 (diff)
server: send attachments to telegram as photos
Diffstat (limited to 'juick-core/src/main/java/com/juick')
-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();
+ }
+ }
}