diff options
author | Vitaly Takmazov | 2018-04-10 10:23:21 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-04-10 10:23:21 +0300 |
commit | 47ca89612bb367ae0a48987e2dc65d77a2b243a4 (patch) | |
tree | 63a184bfc6d7292a7bd562fffbf7449f3d72ab68 /juick-server-xmpp/src | |
parent | a8094e3b0e3c81d8f77f9ccf07d2d5903a4ff5fa (diff) |
fix xmpp flow
Diffstat (limited to 'juick-server-xmpp/src')
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java index 77861373..4d1a73a8 100644 --- a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java @@ -535,19 +535,20 @@ public class XMPPConnection implements StanzaListener, NotificationListener { } return null; } - User user_from; - if (msg.getFrom().getDomain().equals("uid.juick.com")) { - user_from = userService.getUserByUID(NumberUtils.toInt(msg.getFrom().getLocal(), - 0)).orElse(new User()); - } else { - user_from = userService.getUserByJID(msg.getFrom().asBareJid().toEscapedString()); - } - if ((user_from == null || user_from.getUid() == 0) && !msg.getFrom().equals(jid)) { - String signuphash = userService.getSignUpHashByJID(msg.getFrom().asBareJid().toEscapedString()); - return makeReply(msg.getFrom(), "Для того, чтобы начать пользоваться сервисом, пожалуйста пройдите быструю регистрацию: http://juick.com/signup?type=xmpp&hash=" + signuphash + "\nЕсли у вас уже есть учетная запись на Juick, вы сможете присоединить этот JabberID к ней.\n\nTo start using Juick, please sign up: http://juick.com/signup?type=xmpp&hash=" + signuphash + "\nIf you already have an account on Juick, you will be proposed to attach this JabberID to your existing account."); - } Jid to = msg.getTo(); if (to.getDomain().equals(router.getDomain().toEscapedString()) || to.equals(this.jid)) { + User user_from; + if (msg.getFrom().getDomain().equals("uid.juick.com")) { + user_from = userService.getUserByUID(NumberUtils.toInt(msg.getFrom().getLocal(), + 0)).orElse(new User()); + } else { + user_from = userService.getUserByJID(msg.getFrom().asBareJid().toEscapedString()); + } + if ((user_from == null || user_from.getUid() == 0) && !msg.getFrom().equals(jid)) { + String signuphash = userService.getSignUpHashByJID(msg.getFrom().asBareJid().toEscapedString()); + return makeReply(msg.getFrom(), "Для того, чтобы начать пользоваться сервисом, пожалуйста пройдите быструю регистрацию: http://juick.com/signup?type=xmpp&hash=" + signuphash + "\nЕсли у вас уже есть учетная запись на Juick, вы сможете присоединить этот JabberID к ней.\n\nTo start using Juick, please sign up: http://juick.com/signup?type=xmpp&hash=" + signuphash + "\nIf you already have an account on Juick, you will be proposed to attach this JabberID to your existing account."); + } + com.juick.Message jmsg = msg.getExtension(com.juick.Message.class); if (jmsg != null) { if (to.getLocal().equals("pm")) { @@ -570,10 +571,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { } try { if (msg.getTo().equals(jid)) { - result = incomingMessageJuick(user_from, msg.getFrom(), StringUtils.defaultString(msg.getBody()), attachment); - if (result != null) { - router.send(result); - } + return incomingMessageJuick(user_from, msg.getFrom(), StringUtils.defaultString(msg.getBody()), attachment); } else { // PM result = incomingMessageJuick(user_from, msg.getFrom(), @@ -583,8 +581,8 @@ public class XMPPConnection implements StanzaListener, NotificationListener { logger.warn("message exception", e1); } } - } else if (jid.getDomain().endsWith(jid.getDomain()) && (jid.getDomain().equals(this.jid.getDomain()) - || jid.getDomain().endsWith("." + jid.getDomain()))) { + } else if (to.getDomain().endsWith(jid.getDomain()) && (to.getDomain().equals(jid.getDomain()) + || to.getDomain().endsWith("." + jid.getDomain()))) { if (logger.isInfoEnabled()) { try { logger.info("unhandled message: {}", stanzaToString(msg)); |