From: David ‘Bombe’ Roden Date: Wed, 19 Feb 2014 17:17:29 +0000 (+0100) Subject: If no current Sone exists, return an error. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2e03e9dddbea4b81aacaf1aa316f5c3ccffd4bf9;p=Sone.git If no current Sone exists, return an error. --- 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()) {