aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-11-26 03:01:15 +0300
committerGravatar Vitaly Takmazov2022-11-26 03:01:15 +0300
commit0c7bdff5bfdaa44d65972abe90fad4c5cb4631ed (patch)
treeadae18eff9e5107f79d28706d7b53124f58f2714
parent9faf43a6c4b933b5f97be4348d461bf91f5bf2e2 (diff)
Switch to patched babbler version
-rw-r--r--pom.xml13
-rw-r--r--src/main/java/com/juick/XMPPManager.java30
2 files changed, 32 insertions, 11 deletions
diff --git a/pom.xml b/pom.xml
index 21ebdd9d..3a4efe5f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,6 +9,12 @@
<groupId>com.juick</groupId>
<artifactId>juick-api</artifactId>
<version>2.0-SNAPSHOT</version>
+ <repositories>
+ <repository>
+ <id>jitpack.io</id>
+ <url>https://jitpack.io</url>
+ </repository>
+ </repositories>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
@@ -167,7 +173,7 @@
<artifactId>scribejava-apis</artifactId>
<version>8.3.3</version>
</dependency>
- <dependency>
+ <!-- dependency>
<groupId>rocks.xmpp</groupId>
<artifactId>xmpp-core-client</artifactId>
<version>${babbler.version}</version>
@@ -176,6 +182,11 @@
<groupId>rocks.xmpp</groupId>
<artifactId>xmpp-extensions-client</artifactId>
<version>${babbler.version}</version>
+ </dependency -->
+ <dependency>
+ <groupId>com.github.vitalyster</groupId>
+ <artifactId>babbler</artifactId>
+ <version>0ecd48781b</version>
</dependency>
<dependency>
<groupId>org.commonmark</groupId>
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);