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=f25b19c5e73f6276be3bead27972d50e16c3e8ed;hp=7bc9aa94ccb4190901bbf120dc24c321f5d9ec63;hb=a47643aed43d118ca68044f95451bb5374cdb332;hpb=4319fcdc1bd781950db556f1d59b6bf60d495e46 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..f25b19c 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–2012 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 @@ -19,7 +19,9 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.web.WebInterface; +import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; /** @@ -44,7 +46,7 @@ public class DistrustAjaxPage extends JsonPage { * {@inheritDoc} */ @Override - protected JsonObject createJsonObject(Request request) { + protected JsonObject createJsonObject(FreenetRequest request) { Sone currentSone = getCurrentSone(request.getToadletContext(), false); if (currentSone == null) { return createErrorJsonObject("auth-required"); @@ -55,7 +57,11 @@ public class DistrustAjaxPage extends JsonPage { return createErrorJsonObject("invalid-sone-id"); } webInterface.getCore().distrustSone(currentSone, sone); - return createSuccessJsonObject().put("trustValue", webInterface.getCore().getTrust(currentSone, sone).getExplicit()); + Trust trust = webInterface.getCore().getTrust(currentSone, sone); + if (trust == null) { + return createErrorJsonObject("wot-plugin"); + } + return createSuccessJsonObject().put("trustValue", trust.getExplicit()); } }