aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java2
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java8
2 files changed, 9 insertions, 1 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 a96e3180..77861373 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
@@ -542,7 +542,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
} else {
user_from = userService.getUserByJID(msg.getFrom().asBareJid().toEscapedString());
}
- if (user_from == null || user_from.getUid() == 0) {
+ 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.");
}
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 358fac3d..3e17ebce 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
@@ -565,6 +565,14 @@ public class ServerTests {
xmppMessage.setBody("What's up?");
result = router.incomingMessage(xmppMessage);
assertThat(result.getBody(), startsWith("Private message sent"));
+ 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
public void botCommandsTests() throws Exception {