aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-25 19:56:46 +0300
committerGravatar Vitaly Takmazov2018-04-25 19:56:46 +0300
commitcc6ef438b2fa9bbdd7fde2160f67f7c4878eb88b (patch)
tree9c841d7cc1bedbcc5f2f20223d7ae525fde4bd35
parentc5d560428270dd294083f748a186d2d591fe0941 (diff)
server: drop www processing part from xmpp processing
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java30
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java9
2 files changed, 11 insertions, 28 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 59b33aba..0975611a 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -540,13 +540,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
}
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());
- }
+ User 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.");
@@ -554,19 +548,15 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
com.juick.Message jmsg = msg.getExtension(com.juick.Message.class);
if (jmsg != null) {
- if (to.getLocal().equals("pm")) {
- applicationEventPublisher.publishEvent(new MessageEvent(this, jmsg, Collections.singletonList(jmsg.getTo())));
- } else {
- if (MessageUtils.isReply(jmsg)) {
- // to get quote and attachment
- com.juick.Message original = messagesService.getMessage(jmsg.getMid());
- com.juick.Message reply = messagesService.getReply(jmsg.getMid(), jmsg.getRid());
- applicationEventPublisher.publishEvent(new MessageEvent(this, reply,
- subscriptionService.getUsersSubscribedToComments(original, reply)));
- } else if (!MessageUtils.isPM(jmsg)) {
- applicationEventPublisher.publishEvent(new MessageEvent(this,
- messagesService.getMessage(jmsg.getMid()), subscriptionService.getSubscribedUsers(jmsg.getUser().getUid(), jmsg.getMid())));
- }
+ if (MessageUtils.isReply(jmsg)) {
+ // to get quote and attachment
+ com.juick.Message original = messagesService.getMessage(jmsg.getMid());
+ com.juick.Message reply = messagesService.getReply(jmsg.getMid(), jmsg.getRid());
+ applicationEventPublisher.publishEvent(new MessageEvent(this, reply,
+ subscriptionService.getUsersSubscribedToComments(original, reply)));
+ } else if (!MessageUtils.isPM(jmsg)) {
+ applicationEventPublisher.publishEvent(new MessageEvent(this,
+ messagesService.getMessage(jmsg.getMid()), subscriptionService.getSubscribedUsers(jmsg.getUser().getUid(), jmsg.getMid())));
}
} else {
URI attachment = URI.create(StringUtils.EMPTY);
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index 9b9722b2..64f92863 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -60,7 +60,6 @@ import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
-import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.util.UriComponents;
@@ -637,7 +636,7 @@ public class ServerTests {
xmppMessage.setBody("*test test");
result = router.incomingMessage(xmppMessage);
assertThat(result.getBody(), startsWith("New message posted"));
- xmppMessage.setFrom(Jid.of(String.valueOf(renhaId), "uid.juick.com", "perl"));
+ xmppMessage.setFrom(from);
xmppMessage.setBody("PING");
result = router.incomingMessage(xmppMessage);
assertThat(result.getBody(), equalTo("PONG"));
@@ -655,12 +654,6 @@ public class ServerTests {
+ botJid.asBareJid().toEscapedString() + "\" type=\"chat\" id=\"purple553384c6\"><active xmlns=\"http://jabber.org/protocol/chatstates\"></active></message>";
result = router.incomingMessage((rocks.xmpp.core.stanza.model.Message)server.parse(active));
xmppMessage.setFrom(botJid);
- xmppMessage.setTo(botJid.withLocal("pm"));
- Message pm = new Message();
- pm.setUser(userService.getUserByJID(from.toEscapedString()));
- pm.setTo(userService.getUserByUID(secretlySadId).orElseThrow(IllegalAccessError::new));
- xmppMessage.addExtension(pm);
- result = router.incomingMessage(xmppMessage);
// TODO: assert events
}
@Test