X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FCreatePostPage.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FCreatePostPage.java;h=f32e08973a83f9468eee4e3c8ef77575d0b49023;hp=83913b4247a3b9e1186a1dbe9f4363febe31b7ff;hb=2f995a29d8731dc3b3d20e78fd9382be542292ff;hpb=19632b7bb999f888668bdb6d8bdfe0572002b8e4 diff --git a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java index 83913b4..f32e089 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java @@ -17,7 +17,7 @@ package net.pterodactylus.sone.web; -import com.google.common.base.Optional; +import static com.google.common.base.Optional.of; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; @@ -27,6 +27,8 @@ import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.web.Method; +import com.google.common.base.Optional; + /** * This page lets the user create a new {@link Post}. * @@ -63,13 +65,13 @@ public class CreatePostPage extends SoneTemplatePage { String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43); String recipientId = request.getHttpRequest().getPartAsStringFailsafe("recipient", 43); Sone currentSone = getCurrentSone(request.getToadletContext()); - Sone sender = webInterface.getCore().getLocalSone(senderId, false); + Optional sender = webInterface.getCore().getLocalSone(senderId); if (sender == null) { - sender = currentSone; + sender = of(currentSone); } Optional recipient = webInterface.getCore().getSone(recipientId); text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text); - webInterface.getCore().createPost(sender, recipient, System.currentTimeMillis(), text); + webInterface.getCore().createPost(sender.get(), recipient, System.currentTimeMillis(), text); throw new RedirectException(returnPage); } templateContext.set("errorTextEmpty", true);