]> nmode's Git Repositories - signal-cli/commitdiff
Disallow sending an empty message
authorAsamK <asamk@gmx.de>
Tue, 21 Jun 2022 11:55:34 +0000 (13:55 +0200)
committerAsamK <asamk@gmx.de>
Sun, 28 Aug 2022 14:04:05 +0000 (16:04 +0200)
It would be ignored by the offical apps anyway

src/main/java/org/asamk/signal/commands/SendCommand.java

index 57c0c5e9c66c6e6e1045bf118e6c430b863c6f8a..3fd00eaf0d07b27b40b9fdd172372b4f6997deeb 100644 (file)
@@ -170,6 +170,11 @@ public class SendCommand implements JsonRpcLocalCommand {
             previews = List.of();
         }
 
             previews = List.of();
         }
 
+        if (messageText.isEmpty() && attachments.isEmpty() && sticker == null && quote == null) {
+            throw new UserErrorException(
+                    "Sending empty message is not allowed, either a message, attachment or sticker must be given.");
+        }
+
         try {
             var results = m.sendMessage(new Message(messageText,
                     attachments,
         try {
             var results = m.sendMessage(new Message(messageText,
                     attachments,