X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnfollowSoneAjaxPage.java;h=c2379e89175a3ce49dc0e773871f79f22fc525d8;hb=8454806e48890675178c1b4b6cbe4bb9c42b68a3;hp=e9650aaf99c924f6478b4e0dcb8d4909a5b61baa;hpb=01d2e31e5687276b5104edc27c3416d4cd9b89b8;p=Sone.git 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 e9650aa..c2379e8 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,17 +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); - webInterface.core().saveSone(currentSone); - return new JsonObject().put("success", true); + currentSone.removeFriend(soneId); + webInterface.getCore().saveSone(currentSone); + return createSuccessJsonObject(); } }