X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FDistrustAjaxPage.java;h=26a1207ea18b54e1a9ebde9248aba820896a83e8;hp=b86055d5bca71248751d3ef4f3acb986f7942e69;hb=7b55e0be6a3283e43a9bbab98f82aebdd948eb33;hpb=7f024734546973cd592e6cbf04604705477f15f6 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java index b86055d..26a1207 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - DistrustAjaxPage.java - Copyright © 2011–2013 David Roden + * Sone - DistrustAjaxPage.java - Copyright © 2011–2016 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,11 +17,12 @@ package net.pterodactylus.sone.web.ajax; +import com.google.common.base.Optional; + import net.pterodactylus.sone.core.Core; 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 the user distrust a Sone. @@ -45,17 +46,17 @@ public class DistrustAjaxPage extends JsonPage { * {@inheritDoc} */ @Override - protected JsonObject createJsonObject(FreenetRequest request) { + protected JsonReturnObject createJsonObject(FreenetRequest request) { Sone currentSone = getCurrentSone(request.getToadletContext(), false); if (currentSone == null) { return createErrorJsonObject("auth-required"); } String soneId = request.getHttpRequest().getParam("sone"); - Sone sone = webInterface.getCore().getSone(soneId); - if (sone == null) { + Optional sone = webInterface.getCore().getSone(soneId); + if (!sone.isPresent()) { return createErrorJsonObject("invalid-sone-id"); } - webInterface.getCore().distrustSone(currentSone, sone); + webInterface.getCore().distrustSone(currentSone, sone.get()); return createSuccessJsonObject().put("trustValue", webInterface.getCore().getPreferences().getNegativeTrust()); }