From 42af5984ef2decf3763fab51f274fd9940ec23c7 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 23 Feb 2019 17:58:54 +0300 Subject: Do not post empty messages --- src/main/java/com/juick/server/CommandsManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/juick/server/CommandsManager.java b/src/main/java/com/juick/server/CommandsManager.java index 004fbf4f..f6f29941 100644 --- a/src/main/java/com/juick/server/CommandsManager.java +++ b/src/main/java/com/juick/server/CommandsManager.java @@ -128,6 +128,9 @@ public class CommandsManager { : HttpUtils.downloadImage(attachment.toURL(), tmpDir).getHost(); attachmentType = attachmentFName.substring(attachmentFName.length() - 3); } + if (StringUtils.isEmpty(body) && !haveAttachment) { + return CommandResult.fromString("Empty message"); + } int mid = messagesService.createMessage(user.getUid(), body, attachmentType, tags.getRight()); if (haveAttachment) { String fname = String.format("%d.%s", mid, attachmentType); -- cgit v1.2.3