From 2e03e9dddbea4b81aacaf1aa316f5c3ccffd4bf9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 19 Feb 2014 18:17:29 +0100 Subject: [PATCH] If no current Sone exists, return an error. --- .../java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java index 313d271..d8ae229 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java @@ -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 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 = webInterface.getCore().getDatabase().getPost(postId); if (!post.isPresent()) { -- 2.7.4