From 49d632e5e234cf9dbc057d20f5e3eabc34b48969 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 11 Nov 2016 14:38:48 +0300 Subject: xmpp-ft: fix attachment name --- .../src/main/java/com/juick/components/XMPPFTServer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'juick-xmpp-ft/src/main/java/com/juick/components') diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java index e8b9861c..37ca7ec6 100644 --- a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java +++ b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java @@ -1,5 +1,6 @@ package com.juick.components; +import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; @@ -51,17 +52,19 @@ public class XMPPFTServer { msg.setTo(Jid.of(juickJid)); msg.setBody(e.getDescription()); try { - msg.addExtension(new OobX(new URL(filePath.toString()), "!!!!Juick!!")); + String attachmentUrl = DigestUtils.md5Hex(String.format("%s-%s", e.getInitiator().toString(), e.getSessionId()).getBytes()); + msg.addExtension(new OobX(new URL(attachmentUrl), "!!!!Juick!!")); + component.sendMessage(msg); } catch (MalformedURLException e1) { - e1.printStackTrace(); + logger.warn("attachment error", e1); } - component.sendMessage(msg); } }); ft.transfer(); logger.info("transfer started"); } else { e.reject(); + logger.info("transfer rejected"); } } catch (IOException | InterruptedException | ExecutionException e1) { logger.error("ft error", e1); -- cgit v1.2.3