Return an optional Sone from the current session.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / FollowSoneAjaxPage.java
index 071f8e9..3b51df2 100644 (file)
@@ -22,7 +22,6 @@ import com.google.common.base.Optional;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.web.page.FreenetRequest;
-import net.pterodactylus.util.json.JsonObject;
 
 /**
  * AJAX page that lets a Sone follow another Sone.
@@ -45,16 +44,13 @@ public class FollowSoneAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(FreenetRequest request) {
+       protected JsonReturnObject createJsonObject(FreenetRequest request) {
                String soneId = request.getHttpRequest().getParam("sone");
                Optional<Sone> sone = webInterface.getCore().getSone(soneId);
                if (!sone.isPresent()) {
                        return createErrorJsonObject("invalid-sone-id");
                }
-               Sone currentSone = getCurrentSone(request.getToadletContext());
-               if (currentSone == null) {
-                       return createErrorJsonObject("auth-required");
-               }
+               Sone currentSone = getCurrentSone(request.getToadletContext()).get();
                webInterface.getCore().followSone(currentSone, soneId);
                webInterface.getCore().markSoneKnown(sone.get());
                return createSuccessJsonObject();