From 8ee8e53ef593d8551aabe9ab89b6461b87d9e695 Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Fri, 21 Jun 2024 01:23:19 -0400 Subject: [PATCH] Alert notif sources async --- .../me/braydon/profanity/config/AppConfig.java | 3 ++- .../profanity/service/ModerationService.java | 14 +++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/API/src/main/java/me/braydon/profanity/config/AppConfig.java b/API/src/main/java/me/braydon/profanity/config/AppConfig.java index b0a336b..3052552 100644 --- a/API/src/main/java/me/braydon/profanity/config/AppConfig.java +++ b/API/src/main/java/me/braydon/profanity/config/AppConfig.java @@ -3,13 +3,14 @@ package me.braydon.profanity.config; import lombok.NonNull; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * @author Braydon */ -@Configuration +@Configuration @EnableAsync public class AppConfig { @Bean public WebMvcConfigurer configureCors() { diff --git a/API/src/main/java/me/braydon/profanity/service/ModerationService.java b/API/src/main/java/me/braydon/profanity/service/ModerationService.java index ec0c0d8..e0af7d1 100644 --- a/API/src/main/java/me/braydon/profanity/service/ModerationService.java +++ b/API/src/main/java/me/braydon/profanity/service/ModerationService.java @@ -7,6 +7,7 @@ import me.braydon.profanity.notification.INotificationSource; import me.braydon.profanity.notification.NotificationContent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import java.util.List; @@ -18,20 +19,10 @@ import java.util.List; * @author Braydon */ @Service @Log4j2(topic = "Moderation") -public final class ModerationService { +public class ModerationService { @Value("${notifications.enabled}") private boolean enabled; - /** - * # Notification Configuration - * notifications: - * enabled: false - * content: # Elements to display in the notification - * content: true # Should filtered content be displayed? - * matched: true # Should matched content be displayed? - * tags: true # Should obtained tags be displayed? - * score: true # Should the score be displayed? - */ @Value("${notifications.content.content}") private boolean displayContent; @@ -70,6 +61,7 @@ public final class ModerationService { * * @param response the response to handle */ + @Async public void handleAlerts(@NonNull ContentProcessResponse response) { // Disabled or likely safe content, no need to alert anyone if (!enabled || response.getScore() < 0.6D) {