From c257e55a0804ea4769788f7408791a0947eec2f4 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 19 Oct 2017 15:49:47 +0300 Subject: xmpp: fix NPE --- .../main/java/com/juick/components/XMPPConnection.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'juick-xmpp/src') diff --git a/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java b/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java index 8a3beb6a..edf2d0f3 100644 --- a/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java +++ b/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java @@ -17,6 +17,7 @@ package com.juick.components; +import com.juick.Attachment; import com.juick.User; import com.juick.components.s2s.BasicXmppSession; import com.juick.server.helpers.UserInfo; @@ -287,9 +288,9 @@ public class XMPPConnection implements AutoCloseable { } com.juick.Message fullMsg = messagesService.getMessage(jmsg.getMid()); String txt = "@" + jmsg.getUser().getName() + ":" + fullMsg.getTagsString() + "\n"; - String attachment = fullMsg.getAttachment().getMedium().getUrl(); + Attachment attachment = fullMsg.getAttachment(); if (attachment != null) { - txt += attachment + "\n"; + txt += attachment.getMedium().getUrl() + "\n"; } txt += jmsg.getText() + "\n\n"; txt += "#" + jmsg.getMid() + " http://juick.com/" + jmsg.getMid(); @@ -305,7 +306,7 @@ public class XMPPConnection implements AutoCloseable { msg.addExtension(nick); if (attachment != null) { try { - OobX oob = new OobX(new URI(attachment)); + OobX oob = new OobX(new URI(attachment.getMedium().getUrl())); msg.addExtension(oob); } catch (URISyntaxException e) { logger.warn("uri exception", e); @@ -330,9 +331,9 @@ public class XMPPConnection implements AutoCloseable { replyQuote = fullReply.getReplyQuote(); String txt = "Reply by @" + jmsg.getUser().getName() + ":\n" + replyQuote + "\n@" + replyTo + " "; - String attachment = jmsg.getAttachment().getMedium().getUrl(); + Attachment attachment = jmsg.getAttachment(); if (attachment != null) { - txt += attachment + "\n"; + txt += attachment.getMedium().getUrl() + "\n"; } txt += jmsg.getText() + "\n\n" + "#" + jmsg.getMid() + "/" + jmsg.getRid() + " http://juick.com/" + jmsg.getMid() + "#" + jmsg.getRid(); @@ -357,9 +358,9 @@ public class XMPPConnection implements AutoCloseable { String txt = "Recommended by @" + recomm.getUser().getName() + ":\n"; txt += "@" + jmsg.getUser().getName() + ":" + jmsg.getTagsString() + "\n"; - String attachment = jmsg.getAttachment().getMedium().getUrl(); + Attachment attachment = jmsg.getAttachment(); if (attachment != null) { - txt += attachment + "\n"; + txt += attachment.getMedium().getUrl() + "\n"; } txt += jmsg.getText() + "\n\n"; txt += "#" + jmsg.getMid(); @@ -383,7 +384,7 @@ public class XMPPConnection implements AutoCloseable { msg.addExtension(nick); if (attachment != null) { try { - OobX oob = new OobX(new URI(attachment)); + OobX oob = new OobX(new URI(attachment.getMedium().getUrl())); msg.addExtension(oob); } catch (URISyntaxException e) { logger.warn("uri exception", e); -- cgit v1.2.3