From 0c7bdff5bfdaa44d65972abe90fad4c5cb4631ed Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 26 Nov 2022 03:01:15 +0300 Subject: Switch to patched babbler version --- src/main/java/com/juick/XMPPManager.java | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/juick/XMPPManager.java b/src/main/java/com/juick/XMPPManager.java index 0878c450..dcb76853 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); -- cgit v1.2.3