+ * E.g: If {@link ContentTag#ADVERTISEMENT} + * is ignored, advertisements will not be + * filtered. + *
+ */ + private List+ * If the content in the given response + * contains profanity, notification sources + * will be notified. + *
+ * + * @param response the response to handle + */ public void handleAlerts(@NonNull ContentProcessResponse response) { - // Likely safe content, no need to alert anyone - if (response.getScore() < 0.6D) { + // Disabled or likely safe content, no need to alert anyone + if (!enabled || response.getScore() < 0.6D) { return; } - // TODO: handle alerting of the content to the appropriate parties + // Notify sources + int notified = 0; + for (INotificationSource source : notificationSources) { + if (!source.isEnabled()) { + continue; + } + notified++; + source.alert(response, notificationContent); + } + if (notified > 0) { + log.info("Notified {} sources of filtered content", notified); + } } } \ No newline at end of file diff --git a/API/src/main/resources/application.yml b/API/src/main/resources/application.yml index 38c7d58..c039da1 100644 --- a/API/src/main/resources/application.yml +++ b/API/src/main/resources/application.yml @@ -8,6 +8,20 @@ logging: file: path: "./logs" +# 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? + sources: + Discord: + url: "" + username: "TextPurify" + avatar: "https://cdn.rainnny.club/usRQ10FSwaAI.png" + # Spring Configuration spring: data: