aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-10-19 15:49:47 +0300
committerGravatar Vitaly Takmazov2017-10-19 15:49:54 +0300
commitc257e55a0804ea4769788f7408791a0947eec2f4 (patch)
treead15ab7c1b2e7e35aa8e84aae93a0b85a396e666
parent65685f27750a40d4de17f5072cc1097e7aaa7017 (diff)
xmpp: fix NPE
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java17
1 files changed, 9 insertions, 8 deletions
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);