X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FCreatePostAjaxPage.java;h=4c278c615e3eef28f28b9adf9562e638edd58f20;hb=6f019de1d4d9742981d851ac3c9097cca8bff58e;hp=47507948f818c6dfd7371f0629f14a7d6647156a;hpb=99888ce13cc17d49f5e217ab6f2c9ad5ef168792;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java index 4750794..4c278c6 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java @@ -24,6 +24,8 @@ import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; +import com.google.common.base.Optional; + /** * AJAX handler that creates a new post. * @@ -51,7 +53,7 @@ public class CreatePostAjaxPage extends JsonPage { return createErrorJsonObject("auth-required"); } String recipientId = request.getHttpRequest().getParam("recipient"); - Sone recipient = webInterface.getCore().getSone(recipientId, false); + Optional recipient = webInterface.getCore().getSone(recipientId); String senderId = request.getHttpRequest().getParam("sender"); Sone sender = webInterface.getCore().getLocalSone(senderId, false); if (sender == null) { @@ -63,7 +65,7 @@ public class CreatePostAjaxPage extends JsonPage { } text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text); Post newPost = webInterface.getCore().createPost(sender, recipient, text); - return createSuccessJsonObject().put("postId", newPost.getId()).put("sone", sender.getId()).put("recipient", (newPost.getRecipient() != null) ? newPost.getRecipient().getId() : null); + return createSuccessJsonObject().put("postId", newPost.getId()).put("sone", sender.getId()).put("recipient", newPost.getRecipientId().orNull()); } }