aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-common/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java3
-rw-r--r--juick-common/src/main/java/com/juick/server/xmpp/iq/MessageQuery.java10
-rw-r--r--juick-common/src/main/java/com/juick/server/xmpp/iq/package-info.java8
-rw-r--r--juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java8
4 files changed, 28 insertions, 1 deletions
diff --git a/juick-common/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java b/juick-common/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java
index 6bdb819f..5880fd5c 100644
--- a/juick-common/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java
+++ b/juick-common/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.juick.server.xmpp.JidConverter;
+import com.juick.server.xmpp.iq.MessageQuery;
import com.juick.server.xmpp.s2s.BasicXmppSession;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
@@ -87,7 +88,7 @@ public class BaseWebConfiguration implements WebMvcConfigurer, SchedulingConfigu
@Bean
public BasicXmppSession session() {
XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
- .extensions(Extension.of(com.juick.Message.class))
+ .extensions(Extension.of(com.juick.Message.class), Extension.of(MessageQuery.class))
.debugger(LogbackDebugger.class)
.build();
return BasicXmppSession.create(hostname, configuration);
diff --git a/juick-common/src/main/java/com/juick/server/xmpp/iq/MessageQuery.java b/juick-common/src/main/java/com/juick/server/xmpp/iq/MessageQuery.java
new file mode 100644
index 00000000..7500cbf8
--- /dev/null
+++ b/juick-common/src/main/java/com/juick/server/xmpp/iq/MessageQuery.java
@@ -0,0 +1,10 @@
+package com.juick.server.xmpp.iq;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "query")
+public class MessageQuery {
+ private MessageQuery() {
+
+ }
+}
diff --git a/juick-common/src/main/java/com/juick/server/xmpp/iq/package-info.java b/juick-common/src/main/java/com/juick/server/xmpp/iq/package-info.java
new file mode 100644
index 00000000..dada8289
--- /dev/null
+++ b/juick-common/src/main/java/com/juick/server/xmpp/iq/package-info.java
@@ -0,0 +1,8 @@
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlSchema(namespace = "http://juick.com/query#messages", elementFormDefault = XmlNsForm.QUALIFIED)
+package com.juick.server.xmpp.iq;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file
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 bf3f54e1..59b33aba 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
@@ -24,6 +24,7 @@ import com.juick.server.component.PingEvent;
import com.juick.server.component.SubscribeEvent;
import com.juick.server.helpers.CommandResult;
import com.juick.server.helpers.UserInfo;
+import com.juick.server.xmpp.iq.MessageQuery;
import com.juick.server.xmpp.s2s.BasicXmppSession;
import com.juick.server.xmpp.s2s.StanzaListener;
import com.juick.service.*;
@@ -146,6 +147,13 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
} catch (IOException e) {
logger.warn("invalid resource", e);
}
+ router.addIQHandler(MessageQuery.class, iq -> {
+ Message warningMessage = new Message(iq.getFrom(), Message.Type.CHAT);
+ warningMessage.setFrom(jid);
+ warningMessage.setBody("Your XMPP client constantly polls us with XMPP query which is unsupported for years, please find http://juick.com/query#messages in your client code and remove that");
+ router.send(warningMessage);
+ return iq.createError(new StanzaError(Condition.BAD_REQUEST, "Please stop this spam"));
+ });
router.addIQHandler(VCard.class, new AbstractIQHandler(IQ.Type.GET) {
@Override
protected IQ processRequest(IQ iq) {