aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src')
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
index ae7ba2526..edc547eb3 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -24,6 +24,7 @@ import com.juick.server.helpers.UserInfo;
import com.juick.service.MessagesService;
import com.juick.service.SubscriptionService;
import com.juick.service.UserService;
+import com.juick.util.MessageUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
@@ -292,9 +293,9 @@ public class XMPPConnection implements AutoCloseable {
}
com.juick.Message fullMsg = messagesService.getMessage(jmsg.getMid());
String txt = "@" + jmsg.getUser().getName() + ":" + fullMsg.getTagsString() + "\n";
- Attachment attachment = fullMsg.getAttachment();
- if (attachment != null) {
- txt += attachment.getMedium().getUrl() + "\n";
+ String attachmentUrl = MessageUtils.attachmentUrl(fullMsg);
+ if (StringUtils.isNotEmpty(attachmentUrl)) {
+ txt += attachmentUrl + "\n";
}
txt += StringUtils.defaultString(jmsg.getText()) + "\n\n";
txt += "#" + jmsg.getMid() + " http://juick.com/" + jmsg.getMid();
@@ -308,9 +309,9 @@ public class XMPPConnection implements AutoCloseable {
msg.setThread("juick-" + jmsg.getMid());
msg.addExtension(jmsg);
msg.addExtension(nick);
- if (attachment != null) {
+ if (StringUtils.isNotEmpty(attachmentUrl)) {
try {
- OobX oob = new OobX(new URI(attachment.getMedium().getUrl()));
+ OobX oob = new OobX(new URI(attachmentUrl));
msg.addExtension(oob);
} catch (URISyntaxException e) {
logger.warn("uri exception", e);
@@ -335,9 +336,9 @@ public class XMPPConnection implements AutoCloseable {
replyQuote = fullReply.getReplyQuote();
String txt = "Reply by @" + jmsg.getUser().getName() + ":\n" + replyQuote + "\n@" + replyTo + " ";
- Attachment attachment = jmsg.getAttachment();
- if (attachment != null) {
- txt += attachment.getMedium().getUrl() + "\n";
+ String attachmentUrl = MessageUtils.attachmentUrl(fullReply);
+ if (StringUtils.isNotEmpty(attachmentUrl)) {
+ txt += attachmentUrl + "\n";
}
txt += StringUtils.defaultString(jmsg.getText()) + "\n\n" + "#" + jmsg.getMid() + "/" + jmsg.getRid() + " http://juick.com/" + jmsg.getMid() + "#" + jmsg.getRid();
@@ -362,9 +363,9 @@ public class XMPPConnection implements AutoCloseable {
String txt = "Recommended by @" + recomm.getUser().getName() + ":\n";
txt += "@" + jmsg.getUser().getName() + ":" + jmsg.getTagsString() + "\n";
- Attachment attachment = jmsg.getAttachment();
- if (attachment != null) {
- txt += attachment.getMedium().getUrl() + "\n";
+ String attachmentUrl = MessageUtils.attachmentUrl(jmsg);
+ if (StringUtils.isNotEmpty(attachmentUrl)) {
+ txt += attachmentUrl + "\n";
}
txt += StringUtils.defaultString(jmsg.getText()) + "\n\n";
txt += "#" + jmsg.getMid();
@@ -386,9 +387,9 @@ public class XMPPConnection implements AutoCloseable {
msg.setThread("juick-" + jmsg.getMid());
msg.addExtension(jmsg);
msg.addExtension(nick);
- if (attachment != null) {
+ if (StringUtils.isNotEmpty(attachmentUrl)) {
try {
- OobX oob = new OobX(new URI(attachment.getMedium().getUrl()));
+ OobX oob = new OobX(new URI(attachmentUrl));
msg.addExtension(oob);
} catch (URISyntaxException e) {
logger.warn("uri exception", e);