diff options
Diffstat (limited to 'src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java')
-rw-r--r-- | src/main/java/eu/ortlepp/notificationsender/NotificationHandler.java | 6 |
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<>(); |