If no current Sone exists, return an error.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 19 Feb 2014 17:17:29 +0000 (18:17 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:26:09 +0000 (22:26 +0100)
src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java

index 313d271..d8ae229 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.sone.web.ajax;
 
+import static com.google.common.base.Optional.fromNullable;
 import static com.google.common.base.Optional.of;
 
 import net.pterodactylus.sone.data.Post;
@@ -56,7 +57,10 @@ public class CreateReplyAjaxPage extends JsonPage {
                String senderId = request.getHttpRequest().getParam("sender");
                Optional<Sone> sender = webInterface.getCore().getLocalSone(senderId);
                if (!sender.isPresent()) {
-                       sender = of(getCurrentSone(request.getToadletContext()));
+                       sender = fromNullable(getCurrentSone(request.getToadletContext()));
+                       if (!sender.isPresent()) {
+                               return createErrorJsonObject("invalid-sone-id");
+                       }
                }
                Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                if (!post.isPresent()) {