aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/XMPPManager.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-15 23:09:20 +0300
committerGravatar Vitaly Takmazov2022-12-15 23:17:54 +0300
commiteb5d09b7824b4f63e0616c4526215397940c25ad (patch)
tree51b749b80f0a5f3a6f3c0f4f53af079a48fa7dbb /src/main/java/com/juick/XMPPManager.java
parent540760905ebf929e2527034a1a7dc33e3c2a904a (diff)
xmpp: Use `xmppbot_jid` configuration option without conversion
Diffstat (limited to 'src/main/java/com/juick/XMPPManager.java')
-rw-r--r--src/main/java/com/juick/XMPPManager.java73
1 files changed, 27 insertions, 46 deletions
diff --git a/src/main/java/com/juick/XMPPManager.java b/src/main/java/com/juick/XMPPManager.java
index dcb76853..4ff99787 100644
--- a/src/main/java/com/juick/XMPPManager.java
+++ b/src/main/java/com/juick/XMPPManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2020, Juick
+ * Copyright (C) 2008-2022, Juick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -17,29 +17,29 @@
package com.juick;
-import com.juick.model.User;
-import com.juick.util.formatters.PlainTextFormatter;
import com.juick.model.CommandResult;
-import com.juick.www.api.SystemActivity;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.PreDestroy;
-
-import com.juick.www.WebApp;
-import com.juick.util.xmpp.iq.MessageQuery;
+import com.juick.model.User;
import com.juick.service.MessagesService;
import com.juick.service.PMQueriesService;
import com.juick.service.StorageService;
import com.juick.service.UserService;
-import com.juick.service.component.*;
+import com.juick.service.component.NotificationListener;
+import com.juick.service.component.PingEvent;
+import com.juick.service.component.SystemEvent;
import com.juick.util.MessageUtils;
+import com.juick.util.formatters.PlainTextFormatter;
+import com.juick.util.xmpp.iq.MessageQuery;
+import com.juick.www.WebApp;
+import com.juick.www.api.SystemActivity;
+import jakarta.annotation.PostConstruct;
+import jakarta.annotation.PreDestroy;
+import lombok.RequiredArgsConstructor;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import rocks.xmpp.addr.Jid;
import rocks.xmpp.core.XmppException;
@@ -47,7 +47,6 @@ import rocks.xmpp.core.session.Extension;
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;
@@ -71,7 +70,6 @@ import rocks.xmpp.extensions.version.SoftwareVersionManager;
import rocks.xmpp.extensions.version.model.SoftwareVersion;
import javax.annotation.Nonnull;
-import javax.inject.Inject;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
@@ -89,40 +87,24 @@ import java.util.concurrent.Executor;
/**
* @author ugnich
*/
+@RequiredArgsConstructor
public class XMPPManager implements NotificationListener {
-
private static final Logger logger = LoggerFactory.getLogger("XMPP");
-
private ExternalComponent xmpp;
- @Inject
- private CommandsManager commandsManager;
- @Value("${xmppbot_jid:juick@localhost}")
- private Jid jid;
- @Value("${hostname:localhost}")
- private String componentName;
- @Value("${component_port:5347}")
- private int componentPort;
- @Value("${component_host:localhost}")
- private String componentHost;
- @Value("${xmpp_password:secret}")
- private String password;
- @Inject
- private StorageService storageService;
- @Value("classpath:juick.png")
- private Resource vCardImage;
-
- @Inject
- private MessagesService messagesService;
- @Inject
- private UserService userService;
- @Inject
- private PMQueriesService pmQueriesService;
- @Inject
- private Executor applicationTaskExecutor;
- @Inject
- private WebApp webApp;
- @Inject
- private User serviceUser;
+ private final CommandsManager commandsManager;
+ private final Jid jid;
+ private final String componentName;
+ private final int componentPort;
+ private final String componentHost;
+ private final String password;
+ private final StorageService storageService;
+ private final Resource vCardImage;
+
+ private final MessagesService messagesService;
+ private final UserService userService;
+ private final PMQueriesService pmQueriesService;
+ private final Executor applicationTaskExecutor;
+ private final WebApp webApp;
@PostConstruct
public void init() {
@@ -160,7 +142,6 @@ public class XMPPManager implements NotificationListener {
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");