aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/configuration
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/configuration')
-rw-r--r--juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/configuration/EventsConfiguration.java39
2 files changed, 41 insertions, 1 deletions
diff --git a/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java b/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java
index 1ca0130f..8d533f05 100644
--- a/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java
+++ b/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java
@@ -53,7 +53,8 @@ import java.util.Collections;
@EnableSwagger2
@EnableScheduling
@EnableWebSocket
-@Import({ApiSecurityConfig.class, BaseWebConfiguration.class, DataConfiguration.class, StorageConfiguration.class})
+@Import({ApiSecurityConfig.class, BaseWebConfiguration.class, DataConfiguration.class, StorageConfiguration.class,
+EventsConfiguration.class})
@ComponentScan(basePackages = "com.juick.server")
public class ApiAppConfiguration implements WebMvcConfigurer, WebSocketConfigurer {
@Inject
diff --git a/juick-server/src/main/java/com/juick/server/configuration/EventsConfiguration.java b/juick-server/src/main/java/com/juick/server/configuration/EventsConfiguration.java
new file mode 100644
index 00000000..4edc9dde
--- /dev/null
+++ b/juick-server/src/main/java/com/juick/server/configuration/EventsConfiguration.java
@@ -0,0 +1,39 @@
+package com.juick.server.configuration;
+
+import com.juick.server.TelegramBotManager;
+import com.juick.server.XMPPBot;
+import com.juick.server.component.LikeEvent;
+import com.juick.server.component.MessageEvent;
+import com.juick.server.component.SubscribeEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.inject.Inject;
+
+@Configuration
+public class EventsConfiguration {
+ @Inject
+ private TelegramBotManager telegramBotManager;
+ @Inject
+ private XMPPBot bot;
+ @Bean
+ ApplicationListener<MessageEvent> messageListener() {
+ return event -> {
+ telegramBotManager.processMessage(event.getMessage());
+ bot.processMessage(event.getMessage());
+ };
+ }
+ @Bean
+ ApplicationListener<LikeEvent> likeListener() {
+ return event -> {
+ telegramBotManager.processLike(event.getUser(), event.getMessage());
+ };
+ }
+ @Bean
+ ApplicationListener<SubscribeEvent> subscribeListener() {
+ return event -> {
+ telegramBotManager.processSubscribe(event.getUser(), event.getToUser());
+ };
+ }
+}