From cf0137083ce96f8d26e7670332c766a6c7d75faf Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 12 Apr 2018 17:47:45 +0300 Subject: xmpp: warning message for outdated query --- .../src/main/java/com/juick/server/XMPPConnection.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'juick-server-xmpp') 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) { -- cgit v1.2.3