From 9872c0e72e4a568232eafdb74ef131e05c6f4f62 Mon Sep 17 00:00:00 2001 From: j-dimension Date: Mon, 6 Nov 2023 00:59:44 +0100 Subject: [PATCH] prevent instant messages with empty body / content. close #2174 --- .../src/java/org/jlawyer/io/rest/v7/MessagingEndpointV7.java | 2 +- .../com/jdimension/jlawyer/services/MessagingService.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v7/MessagingEndpointV7.java b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v7/MessagingEndpointV7.java index 38358bd43..9840d7cf8 100644 --- a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v7/MessagingEndpointV7.java +++ b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v7/MessagingEndpointV7.java @@ -714,7 +714,7 @@ public Response submitMessage(RestfulInstantMessageV7 msg) { try { if (msg.getSender() == null || "".equals(msg.getSender())) { - log.error("Can not submit new messgae - no sender given"); + log.error("Can not submit new message - no sender given"); return Response.serverError().build(); } diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/MessagingService.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/MessagingService.java index de6edbf62..415bc24c1 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/MessagingService.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/MessagingService.java @@ -718,6 +718,10 @@ public class MessagingService implements MessagingServiceRemote, MessagingServic @Override @RolesAllowed({"loginRole"}) public InstantMessage submitMessage(InstantMessage message) throws Exception { + + if(message.getContent()==null || message.getContent().trim().isEmpty()) + throw new Exception("Nachricht ohne Inhalt"); + StringGenerator idGen = new StringGenerator(); String messageId=idGen.getID().toString(); message.setId(messageId);