aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp-ft/src/main/java/com/juick/components
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-11-11 15:34:38 +0300
committerGravatar Vitaly Takmazov2016-11-11 15:34:38 +0300
commit3069c76cc870fded9bef581a218b68fa4e38fd49 (patch)
treea7cc07fcc50265d2c5294b4f1a18efb36ed00ddb /juick-xmpp-ft/src/main/java/com/juick/components
parent6efc3d0aaa31b250c9dfef04ece02f7d6c1d782b (diff)
xmpp-ft: fix target filename
Diffstat (limited to 'juick-xmpp-ft/src/main/java/com/juick/components')
-rw-r--r--juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java10
1 files changed, 5 insertions, 5 deletions
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 05f2b465..e922e7fa 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
@@ -57,8 +57,11 @@ public class XMPPFTServer {
try {
List<String> allowedTypes = new ArrayList<String>() {{ add("png"); add("jpg"); }};
String attachmentExtension = FilenameUtils.getExtension(e.getName());
+ String targetFilename = String.format("%s.%s",
+ DigestUtils.md5Hex(String.format("%s-%s",
+ e.getInitiator().toString(), e.getSessionId()).getBytes()), attachmentExtension);
if (allowedTypes.contains(attachmentExtension)) {
- Path filePath = Paths.get(tmpDir, e.getName());
+ Path filePath = Paths.get(tmpDir, targetFilename);
FileTransfer ft = e.accept(filePath).get();
ft.addFileTransferStatusListener(st -> {
logger.debug(String.format("%s: received %d of %d", e.getName(), st.getBytesTransferred(), e.getSize()));
@@ -70,10 +73,7 @@ public class XMPPFTServer {
msg.setTo(Jid.of(juickJid));
msg.setBody(e.getDescription());
try {
- String attachmentUrl = String.format("juick://%s.%s",
- DigestUtils.md5Hex(String.format("%s-%s",
- e.getInitiator().toString(), e.getSessionId()).getBytes()),
- attachmentExtension);
+ String attachmentUrl = String.format("juick://%s", targetFilename);
msg.addExtension(new OobX(new URI(attachmentUrl).toURL(), "!!!!Juick!!"));
component.sendMessage(msg);
} catch (MalformedURLException | URISyntaxException e1) {