aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java
diff options
context:
space:
mode:
authorThorsten Ortlepp <post@ortlepp.eu>2024-05-07 00:07:36 +0200
committerThorsten Ortlepp <post@ortlepp.eu>2024-05-07 00:07:36 +0200
commitb0a3a919b7f6f82cf2afa780132dfefeddf78418 (patch)
treebd3c112a3772ad5b34679fa08257e53b9fa23325 /src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java
parentfdf19cdf6446815ed155bfb70564e5af8bdedd74 (diff)
downloadnotification-sender-b0a3a919b7f6f82cf2afa780132dfefeddf78418.zip
omit empty notifications
Diffstat (limited to 'src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java')
-rw-r--r--src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java b/src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java
index 17b4a46..6a93992 100644
--- a/src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java
+++ b/src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java
@@ -78,7 +78,7 @@ public class NotificationHandler implements RequestHandler<Map<String, Object>,
/**
- * Extract the notifications from the input JSON.
+ * Extract the notifications from the input JSON. Omit empty notifications.
*
* @param body The input JSON
* @return The extracted messages; empty list if an error occurred while parsing the JSON
@@ -87,7 +87,9 @@ public class NotificationHandler implements RequestHandler<Map<String, Object>,
try {
Notifications notifications =
new ObjectMapper().readValue(body.toString(), Notifications.class);
- return Arrays.asList(notifications.messages());
+ var messages = new ArrayList<>(Arrays.asList(notifications.messages()));
+ messages.removeIf(message -> message.trim().isEmpty());
+ return messages;
} catch (JsonProcessingException ex) {
logger.log("parsing input JSON failed : " + ex.getMessage());
return new ArrayList<>();