aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/XMPPConnection.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-30 17:52:53 +0300
committerGravatar Vitaly Takmazov2018-03-30 17:52:53 +0300
commitbda2d764a9c187da5aa8cd74fb8c4a9574d3996e (patch)
tree2d5bc98a5744f8f6a0ec4e7f9893c2355235267c /juick-server/src/main/java/com/juick/server/XMPPConnection.java
parent7eb13edc1720b13924d7cbe715be67a535f0e02e (diff)
xmpp integration tests
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/XMPPConnection.java')
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java21
1 files changed, 18 insertions, 3 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 406294a1..40cf347a 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -36,6 +36,7 @@ import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -95,7 +96,6 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
private CommandsManager commandsManager;
@Value("${xmppbot_jid:juick@localhost}")
private Jid jid;
-
@Value("${componentname:localhost}")
private String componentName;
@Value("${component_port:5347}")
@@ -201,6 +201,17 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
messagesService.getMessage(jmsg.getMid())));
}
}
+ } else {
+ String attachment = StringUtils.EMPTY;
+ OobX oobX = message.getExtension(OobX.class);
+ if (oobX != null) {
+ attachment = oobX.getUri().toString();
+ }
+ try {
+ serverManager.processMessage(userService.getUserByUID(NumberUtils.toInt(message.getFrom().getLocal(), 0)).orElse(new User()), message.getBody(), attachment);
+ } catch (Exception e1) {
+ logger.warn("message exception", e1);
+ }
}
} else if (jid.getDomain().endsWith(jid.getDomain()) && (jid.getDomain().equals(this.jid.getDomain())
|| jid.getDomain().endsWith("." + jid.getDomain()))) {
@@ -607,7 +618,11 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
if (username.equals(jid.getLocal())) {
try {
OobX oobX = msg.getExtension(OobX.class);
- incomingMessageJuick(user_from, msg.getFrom(), msg.getBody().trim(), oobX.getUri());
+ if (oobX != null) {
+ incomingMessageJuick(user_from, msg.getFrom(), msg.getBody().trim(), oobX.getUri());
+ } else {
+ incomingMessageJuick(user_from, msg.getFrom(), msg.getBody().trim(), null);
+ }
} catch (Exception e) {
return;
}
@@ -669,7 +684,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
int mid = messagesService.createMessage(user_from.getUid(), body, attachmentType, tags);
subscriptionService.subscribeMessage(mid, user_from.getUid());
if (StringUtils.isNotEmpty(attachmentType)) {
- String attachmentFName = attachment.getScheme().equals("juick") ? attachment.getPath()
+ String attachmentFName = attachment.getScheme().equals("juick") ? attachment.getHost()
: HttpUtils.downloadImage(attachment.toURL(), tmpDir);
String fname = String.format("%d.%s", mid, attachmentType);
ImageUtils.saveImageWithPreviews(attachmentFName, fname, tmpDir, imgDir);