diff --git a/README.md b/README.md index f3a46d5..e1e5ba7 100644 --- a/README.md +++ b/README.md @@ -95,13 +95,14 @@ You can now also attach breakpoints in code for debugging purposes, by clicking *Apus* can be started without any specific configuration. All configuration options have working default values. To modify these default values just specify environment variables with the following names: -| Variable | Default | Description | -|-------------------|-----------------|---------------------------------------------------------| -| DOAG_EVENT_ID | 0 | The ID of the DOAG event to read the conference agenda. | -| FILTER_REPLIES | true | Hide social media messages which are replies. | -| MASTODON_INSTANCE | mastodon.social | The Mastodon instance used to read the posts from. | -| MASTODON_HASHTAG | java | The hashtag for the mastodon wall. | -| TZ | UTC | The timezone used for date and time calculations. | +| Variable | Default | Description | +|-------------------|-----------------|-----------------------------------------------------------------| +| DOAG_EVENT_ID | 0 | The ID of the DOAG event to read the conference agenda. | +| FILTER_REPLIES | true | Hide social media messages which are replies. | +| FILTER_SENSITIVE | true | Hide social media messages which contain sensitive information. | +| MASTODON_INSTANCE | mastodon.social | The Mastodon instance used to read the posts from. | +| MASTODON_HASHTAG | java | The hashtag for the mastodon wall. | +| TZ | UTC | The timezone used for date and time calculations. | The environment variables will override the default values. diff --git a/src/main/java/swiss/fihlon/apus/configuration/Filter.java b/src/main/java/swiss/fihlon/apus/configuration/Filter.java index 1d01f30..3118068 100644 --- a/src/main/java/swiss/fihlon/apus/configuration/Filter.java +++ b/src/main/java/swiss/fihlon/apus/configuration/Filter.java @@ -17,4 +17,4 @@ */ package swiss.fihlon.apus.configuration; -public record Filter(boolean replies) { } +public record Filter(boolean replies, boolean sensitive) { } diff --git a/src/main/java/swiss/fihlon/apus/service/SocialService.java b/src/main/java/swiss/fihlon/apus/service/SocialService.java index 9cf192f..fed1104 100644 --- a/src/main/java/swiss/fihlon/apus/service/SocialService.java +++ b/src/main/java/swiss/fihlon/apus/service/SocialService.java @@ -39,6 +39,7 @@ public final class SocialService { private final MastodonAPI mastodonAPI; private final String hashtag; private final boolean filterReplies; + private final boolean filterSensitive; private List messages = List.of(); public SocialService(@NotNull final TaskScheduler taskScheduler, @@ -46,6 +47,7 @@ public SocialService(@NotNull final TaskScheduler taskScheduler, mastodonAPI = new MastodonAPI(configuration.getMastodon().instance()); hashtag = configuration.getMastodon().hashtag(); filterReplies = configuration.getFilter().replies(); + filterSensitive = configuration.getFilter().sensitive(); updateMessages(); updateScheduler = taskScheduler.scheduleAtFixedRate(this::updateMessages, UPDATE_FREQUENCY); } @@ -57,7 +59,7 @@ public void stopUpdateScheduler() { private void updateMessages() { final var newMessages = mastodonAPI.getMessages(hashtag).stream() - .filter(message -> !message.isSensitive()) + .filter(message -> !filterSensitive || !message.isSensitive()) .filter(message -> !filterReplies || !message.isReply()) .toList(); synchronized (this) { diff --git a/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 2a59bf8..13e8459 100644 --- a/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -19,5 +19,10 @@ "name": "apus.filter.replies", "type": "java.lang.Boolean", "description": "Hide social media messages which are replies." + }, + { + "name": "apus.filter.sensitive", + "type": "java.lang.Boolean", + "description": "Hide social media messages which contain sensitive information." } ] } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e7ee325..7ac86cb 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -13,3 +13,4 @@ apus.doag.eventId=${DOAG_EVENT_ID:0} apus.mastodon.instance=${MASTODON_INSTANCE:mastodon.social} apus.mastodon.hashtag=${MASTODON_HASHTAG:java} apus.filter.replies=${FILTER_REPLIES:true} +apus.filter.sensitive=${FILTER_SENSITIVE:true}