diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/juick/XMPPManager.java | 73 | ||||
-rw-r--r-- | src/main/java/com/juick/config/XMPPConfig.java | 48 |
2 files changed, 68 insertions, 53 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"); diff --git a/src/main/java/com/juick/config/XMPPConfig.java b/src/main/java/com/juick/config/XMPPConfig.java index 8604b52b..534909a5 100644 --- a/src/main/java/com/juick/config/XMPPConfig.java +++ b/src/main/java/com/juick/config/XMPPConfig.java @@ -17,24 +17,58 @@ package com.juick.config; +import com.juick.CommandsManager; import com.juick.XMPPManager; -import com.juick.util.xmpp.JidConverter; +import com.juick.service.MessagesService; +import com.juick.service.PMQueriesService; +import com.juick.service.StorageService; +import com.juick.service.UserService; +import com.juick.www.WebApp; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import rocks.xmpp.addr.Jid; + +import javax.inject.Inject; +import java.util.concurrent.Executor; @Configuration @ConditionalOnProperty("xmppbot_jid") public class XMPPConfig { - - @Bean - JidConverter jidConverter() { - return new JidConverter(); - } + @Value("${xmppbot_jid:juick@localhost}") + private String botJid; + @Value("${hostname:localhost}") + private String componentName; + @Value("${component_port:5347}") + private int componentPort; + @Value("${component_host:localhost}") + private String componentHost; + @Inject + private CommandsManager commandsManager; + @Value("${xmpp_password:secret}") + private String password; + @Value("classpath:juick.png") + private Resource vCardImage; + @Inject + private StorageService storageService; + @Inject + private MessagesService messagesService; + @Inject + private UserService userService; + @Inject + private PMQueriesService pmQueriesService; + @Inject + private Executor applicationTaskExecutor; + @Inject + private WebApp webApp; @Bean XMPPManager xmppConnection() { - return new XMPPManager(); + return new XMPPManager(commandsManager, Jid.of(botJid), componentName, componentPort, + componentHost, password, storageService, vCardImage, messagesService, userService, pmQueriesService, + applicationTaskExecutor, webApp); } } |