From: David ‘Bombe’ Roden Date: Wed, 21 Nov 2012 21:33:39 +0000 (+0100) Subject: Do not allow creation of empty posts and replies. X-Git-Tag: 0.8.5^2~15 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=536ff0d46064e9e3a197cd41060e6660c696ac67 Do not allow creation of empty posts and replies. This should fix #304. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 4761959..37c026f 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1579,6 +1579,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis * @return The created post */ public Post createPost(Sone sone, Sone recipient, long time, String text) { + Validation.begin().isNotNull("Text", text).check().isGreater("Text Length", text.length(), 0).check(); if (!isLocalSone(sone)) { logger.log(Level.FINE, String.format("Tried to create post for non-local Sone: %s", sone)); return null; @@ -1719,6 +1720,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis * @return The created reply */ public PostReply createReply(Sone sone, Post post, long time, String text) { + Validation.begin().isNotNull("Text", text).check().isGreater("Text Length", text.trim().length(), 0).check(); if (!isLocalSone(sone)) { logger.log(Level.FINE, String.format("Tried to create reply for non-local Sone: %s", sone)); return null;