X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FDistrustAjaxPage.java;h=2694abf190b5c287504450921e160163dc7d7f76;hb=e14e8aff491d7a04e4e04ed9c38bcae630195655;hp=7bc9aa94ccb4190901bbf120dc24c321f5d9ec63;hpb=4319fcdc1bd781950db556f1d59b6bf60d495e46;p=Sone.git 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 7bc9aa9..2694abf 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 - TrustAjaxPage.java - Copyright © 2011 David Roden + * Sone - DistrustAjaxPage.java - Copyright © 2011–2013 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 @@ -20,7 +20,9 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.WebInterface; -import net.pterodactylus.util.json.JsonObject; +import net.pterodactylus.sone.web.page.FreenetRequest; + +import com.google.common.base.Optional; /** * AJAX page that lets the user distrust a Sone. @@ -40,22 +42,19 @@ public class DistrustAjaxPage extends JsonPage { super("distrustSone.ajax", webInterface); } - /** - * {@inheritDoc} - */ @Override - protected JsonObject createJsonObject(Request 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, false); - if (sone == null) { + Optional sone = webInterface.getCore().getSone(soneId); + if (!sone.isPresent()) { return createErrorJsonObject("invalid-sone-id"); } - webInterface.getCore().distrustSone(currentSone, sone); - return createSuccessJsonObject().put("trustValue", webInterface.getCore().getTrust(currentSone, sone).getExplicit()); + webInterface.getCore().distrustSone(currentSone, sone.get()); + return createSuccessJsonObject().put("trustValue", webInterface.getCore().getPreferences().getNegativeTrust()); } }