aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-common/src/main/java/com/juick/Message.java1
-rw-r--r--juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java32
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java5
-rw-r--r--juick-www/build.gradle1
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java2
5 files changed, 23 insertions, 18 deletions
diff --git a/juick-common/src/main/java/com/juick/Message.java b/juick-common/src/main/java/com/juick/Message.java
index e574e3cc..155c1747 100644
--- a/juick-common/src/main/java/com/juick/Message.java
+++ b/juick-common/src/main/java/com/juick/Message.java
@@ -283,6 +283,7 @@ public class Message implements Comparable {
this.attachment = attachment;
}
+ @XmlTransient
public Instant getUpdated() {
return updated;
}
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));
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 3e17ebce..a9cb306b 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,11 @@ public class ServerTests {
xmppMessage.setBody("What's up?");
result = router.incomingMessage(xmppMessage);
assertThat(result.getBody(), startsWith("Private message sent"));
+ String xml = "<message xmlns=\"jabber:server\" from=\"juick@localhost\" to=\"renha@serverstorageisfull.tld\" type=\"chat\"><body>@yo:\n" +
+ "343432434\n" +
+ "\n" +
+ "#2 http://juick.com/2</body><thread>juick-2</thread><juick xmlns=\"http://juick.com/message\" mid=\"2\" privacy=\"1\" quote=\"\" replyto=\"0\" rid=\"0\" ts=\"2018-04-10 06:58:23\"><body>343432434</body><updated></updated><user xmlns=\"http://juick.com/user\" uname=\"yo\" uid=\"2\"></user></juick><nick xmlns=\"http://jabber.org/protocol/nick\">@yo</nick></message>";
+ result = router.incomingMessage((rocks.xmpp.core.stanza.model.Message)server.parse(xml));
xmppMessage.setFrom(botJid);
xmppMessage.setTo(botJid.withLocal("pm"));
Message pm = new Message();
diff --git a/juick-www/build.gradle b/juick-www/build.gradle
index 9e1ee3e4..2134b57e 100644
--- a/juick-www/build.gradle
+++ b/juick-www/build.gradle
@@ -31,6 +31,7 @@ dependencies {
compile("org.springframework.boot:spring-boot-starter-cache")
compile("org.springframework.boot:spring-boot-starter-web")
compile ('org.springframework.boot:spring-boot-starter-security')
+ providedRuntime("org.springframework.boot:spring-boot-devtools")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
providedRuntime 'com.h2database:h2:1.4.196'
providedRuntime 'mysql:mysql-connector-java:5.1.45'
diff --git a/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
index 4de79363..b13d03f5 100644
--- a/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
@@ -135,6 +135,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.debug(false);
- web.ignoring().antMatchers("/style.css*", "/scripts.js*", "/h2-console", "/.well-known/**");
+ web.ignoring().antMatchers("/style.css*", "/scripts.js*", "/h2-console/**", "/.well-known/**");
}
}