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=7f719b7c0904aae418966b6b611fe7a0c5b76e67;hp=012b9cfb1c97ac4890ddf41fd91093b46f38ec8e;hb=89a905395984ec35e313b07594e21773ffd3d9d8;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..7f719b7 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java @@ -35,7 +35,7 @@ public class UnfollowSoneAjaxPage extends JsonPage { * The Sone web interface */ public UnfollowSoneAjaxPage(WebInterface webInterface) { - super("ajax/unfollowSone.ajax", webInterface); + super("unfollowSone.ajax", webInterface); } /** @@ -44,16 +44,16 @@ public class UnfollowSoneAjaxPage extends JsonPage { @Override protected JsonObject createJsonObject(Request 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(); } }