aboutsummaryrefslogtreecommitdiff
path: root/juick-server-xmpp/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-09 19:03:53 +0300
committerGravatar Vitaly Takmazov2018-04-09 19:03:53 +0300
commit7eb191f93473f61febeb8bd195fc1b3127cfcc6d (patch)
tree3cde97dd636719046555f757f55d756b8e9da145 /juick-server-xmpp/src
parent66fd14b44044b2b8004ddd73789345e5c7f26ae2 (diff)
server: xmpp pm tests
Diffstat (limited to 'juick-server-xmpp/src')
-rw-r--r--juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java41
1 files changed, 6 insertions, 35 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 c73b7cb1..a96e3180 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
@@ -546,11 +546,11 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
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 jid = msg.getTo();
- if (jid.getDomain().equals(router.getDomain().toEscapedString()) || jid.equals(this.jid)) {
+ Jid to = msg.getTo();
+ if (to.getDomain().equals(router.getDomain().toEscapedString()) || to.equals(this.jid)) {
com.juick.Message jmsg = msg.getExtension(com.juick.Message.class);
if (jmsg != null) {
- if (jid.getLocal().equals("pm")) {
+ if (to.getLocal().equals("pm")) {
applicationEventPublisher.publishEvent(new MessageEvent(this, jmsg));
} else {
if (MessageUtils.isReply(jmsg)) {
@@ -575,38 +575,9 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
router.send(result);
}
} else {
- int uid_to = userService.getUIDbyName(msg.getTo().getLocal());
-
- if (uid_to == 0) {
- Message reply = new Message();
- reply.setFrom(msg.getTo());
- reply.setTo(msg.getFrom());
- reply.setType(Message.Type.ERROR);
- reply.setId(msg.getId());
- reply.setError(new StanzaError(StanzaError.Type.CANCEL, Condition.ITEM_NOT_FOUND));
- return ClientMessage.from(reply);
- }
-
- boolean success = false;
- if (!userService.isInBLAny(uid_to, user_from.getUid())) {
- success = pmQueriesService.createPM(user_from.getUid(), uid_to, msg.getBody());
- }
-
- if (success) {
- com.juick.Message pm = new com.juick.Message();
- pm.setUser(user_from);
- pm.setTo(userService.getUserByUID(uid_to).get());
- pm.setText(msg.getBody());
- applicationEventPublisher.publishEvent(new MessageEvent(this, pm));
- } else {
- Message reply = new Message();
- reply.setFrom(msg.getTo());
- reply.setTo(msg.getFrom());
- reply.setType(Message.Type.ERROR);
- reply.setId(msg.getId());
- reply.setError(new StanzaError(StanzaError.Type.CANCEL, Condition.NOT_ALLOWED));
- return ClientMessage.from(reply);
- }
+ // PM
+ result = incomingMessageJuick(user_from, msg.getFrom(),
+ String.format("@%s %s", msg.getTo().getLocal(), StringUtils.defaultString(msg.getBody())), attachment);
}
} catch (Exception e1) {
logger.warn("message exception", e1);