X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FTrustAjaxPage.java;h=d03e030ecabc205ad0accd07957b591f9be6fee3;hp=9329c1ba46eee9a3f5ecb889717cae0860a13cbb;hb=45803a1c678d6811f7bbf85d50c79844031be0f0;hpb=33cc85447797301e299e7ac444fe53538f09a69d diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java index 9329c1b..d03e030 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java @@ -17,6 +17,8 @@ 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; @@ -51,11 +53,11 @@ public class TrustAjaxPage extends JsonPage { 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().trustSone(currentSone, sone); + webInterface.getCore().trustSone(currentSone, sone.get()); return createSuccessJsonObject().put("trustValue", webInterface.getCore().getPreferences().getPositiveTrust()); }