X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnfollowSoneAjaxPage.java;h=26f1a1156dd085f87ccf272e1314a785052513ff;hp=012b9cfb1c97ac4890ddf41fd91093b46f38ec8e;hb=45f92ec63dbf8134d92ceed67294faa38117b195;hpb=47df88512f5288d6a1f5f268cdf787bb4bf169c7 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java index 012b9cf..26f1a11 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax; 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; /** @@ -35,25 +36,25 @@ public class UnfollowSoneAjaxPage extends JsonPage { * The Sone web interface */ public UnfollowSoneAjaxPage(WebInterface webInterface) { - super("ajax/unfollowSone.ajax", webInterface); + super("unfollowSone.ajax", webInterface); } /** * {@inheritDoc} */ @Override - protected JsonObject createJsonObject(Request request) { + protected JsonObject createJsonObject(FreenetRequest request) { String soneId = request.getHttpRequest().getParam("sone"); - Sone sone = webInterface.core().getSone(soneId); - if (sone == null) { - return new JsonObject().put("success", false).put("error", "invalid-sone-id"); + if (!webInterface.getCore().hasSone(soneId)) { + return createErrorJsonObject("invalid-sone-id"); } Sone currentSone = getCurrentSone(request.getToadletContext()); if (currentSone == null) { - return new JsonObject().put("success", false).put("error", "auth-required"); + return createErrorJsonObject("auth-required"); } - currentSone.removeFriend(sone); - return new JsonObject().put("success", true); + currentSone.removeFriend(soneId); + webInterface.getCore().touchConfiguration(); + return createSuccessJsonObject(); } }