aboutsummaryrefslogtreecommitdiff
path: root/juick-server-xmpp/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-xmpp/src/main/java')
-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 c73b7cb1d..a96e3180e 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);