Return local Sones from core and web interface.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / CreateReplyPage.java
index 4158313..3ec13f6 100644 (file)
@@ -19,8 +19,8 @@ package net.pterodactylus.sone.web;
 
 import com.google.common.base.Optional;
 
+import net.pterodactylus.sone.data.LocalSone;
 import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.text.TextFilter;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.template.Template;
@@ -66,12 +66,12 @@ public class CreateReplyPage extends SoneTemplatePage {
                        }
                        if (text.length() > 0) {
                                String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43);
-                               Sone sender = webInterface.getCore().getLocalSone(senderId);
-                               if (sender == null) {
-                                       sender = getCurrentSone(request.getToadletContext()).get();
+                               Optional<LocalSone> sender = webInterface.getCore().getLocalSone(senderId);
+                               if (!sender.isPresent()) {
+                                       sender = getCurrentSone(request.getToadletContext());
                                }
                                text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text);
-                               webInterface.getCore().createReply(sender, post.get(), text);
+                               webInterface.getCore().createReply(sender.get(), post.get(), text);
                                throw new RedirectException(returnPage);
                        }
                        templateContext.set("errorTextEmpty", true);