From 2a5753cb32dd184d66ee28d38881c9135f8526c4 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 21 Feb 2018 23:52:11 +0300 Subject: server: send attachments to telegram as photos --- .../src/main/java/com/juick/util/MessageUtils.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'juick-core/src/main/java/com/juick/util') 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(); + } + } } -- cgit v1.2.3