diff options
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r-- | src/main/java/com/juick/XMPPManager.java | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/main/java/com/juick/XMPPManager.java b/src/main/java/com/juick/XMPPManager.java index 0878c4506..dcb76853e 100644 --- a/src/main/java/com/juick/XMPPManager.java +++ b/src/main/java/com/juick/XMPPManager.java @@ -48,6 +48,7 @@ import rocks.xmpp.core.session.XmppSession; import rocks.xmpp.core.session.XmppSessionConfiguration; import rocks.xmpp.core.session.debug.LogbackDebugger; import rocks.xmpp.core.stanza.AbstractIQHandler; +import rocks.xmpp.core.stanza.IQHandler; import rocks.xmpp.core.stanza.model.IQ; import rocks.xmpp.core.stanza.model.Message; import rocks.xmpp.core.stanza.model.Presence; @@ -135,7 +136,7 @@ public class XMPPManager implements NotificationListener { ServiceDiscoveryManager serviceDiscoveryManager = xmpp.getManager(ServiceDiscoveryManager.class); serviceDiscoveryManager.addIdentity(Identity.clientBot().withName("Juick")); EntityCapabilitiesManager entityCapabilitiesManager = xmpp.getManager(EntityCapabilitiesManager.class); - entityCapabilitiesManager.setNode("https://juick.com/caps"); + //entityCapabilitiesManager.setNode("https://juick.com/caps"); MessageDeliveryReceiptsManager messageDeliveryReceiptsManager = xmpp.getManager(MessageDeliveryReceiptsManager.class); messageDeliveryReceiptsManager.setEnabled(true); PingManager pingManager = xmpp.getManager(PingManager.class); @@ -154,16 +155,25 @@ public class XMPPManager implements NotificationListener { } catch (IOException e) { logger.warn("invalid resource", e); } - xmpp.addIQHandler(MessageQuery.class, iq -> { - Message warningMessage = new Message(iq.getFrom(), Message.Type.CHAT); - warningMessage.setFrom(jid); - warningMessage.setBody("Please, stop this shit"); - xmpp.send(warningMessage); - return iq.createError(new StanzaError(Condition.BAD_REQUEST, "Please stop this spam")); + xmpp.addIQHandler(new IQHandler() { + public java.lang.Class<?> getPayloadClass() { + return MessageQuery.class; + } + public IQ handleRequest(IQ iq) { + MessageQuery query = iq.getExtension(MessageQuery.class); + Message warningMessage = new Message(iq.getFrom(), Message.Type.CHAT); + warningMessage.setFrom(jid); + warningMessage.setBody("Please, stop this shit"); + xmpp.send(warningMessage); + return iq.createError(new StanzaError(Condition.BAD_REQUEST, "Please stop this spam")); + } }); - xmpp.addIQHandler(VCard.class, new AbstractIQHandler(IQ.Type.GET) { - @Override - protected IQ processRequest(IQ iq) { + xmpp.addIQHandler(new IQHandler() { + public Class<?> getPayloadClass() { + return VCard.class; + } + @Override + public IQ handleRequest(IQ iq) { if (iq.getTo().equals(jid) || iq.getTo().asBareJid().equals(jid.asBareJid()) || iq.getTo().asBareJid().toEscapedString().equals(jid.getDomain())) { return iq.createResult(vCard); |