X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FCreateReplyPage.java;h=481199767a86dfe663a5595a3a5c1b08f4c1dac8;hb=c4eb31ab64627adfdeed2a445d67883371203e99;hp=c8979c150483c059e13b580fcc623e7d89adc11b;hpb=7bf3f34153d68c6c74245e24d0957aa11e93b056;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java index c8979c1..4811997 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.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 post a reply to a post. * @@ -50,9 +52,6 @@ public class CreateReplyPage extends SoneTemplatePage { // TEMPLATEPAGE METHODS // - /** - * {@inheritDoc} - */ @Override protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); @@ -60,18 +59,18 @@ public class CreateReplyPage extends SoneTemplatePage { String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim(); String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); if (request.getMethod() == Method.POST) { - Optional post = webInterface.getCore().getPost(postId); + Optional post = webInterface.getCore().getDatabase().getPost(postId); if (!post.isPresent()) { throw new RedirectException("noPermission.html"); } if (text.length() > 0) { String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43); - Sone sender = webInterface.getCore().getLocalSone(senderId, false); - if (sender == null) { - sender = getCurrentSone(request.getToadletContext()); + Optional sender = webInterface.getCore().getLocalSone(senderId); + if (!sender.isPresent()) { + sender = of(getCurrentSone(request.getToadletContext())); } text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text); - webInterface.getCore().createReply(sender, post.get(), text); + sender.get().newPostReplyBuilder(post.get().getId()).withText(text).build(webInterface.getCore().postReplyCreated()); throw new RedirectException(returnPage); } templateContext.set("errorTextEmpty", true);