X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnlikeAjaxPage.java;h=e5c933dbfaeb497276357f1d72d705bdd3f8369f;hb=8454806e48890675178c1b4b6cbe4bb9c42b68a3;hp=a6a325abd4529dd4284475f479085ea0b73688ae;hpb=16a69fdf1e4d4b7852ca8e2abdfd09470207ec6b;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java index a6a325a..e5c933d 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java @@ -33,9 +33,10 @@ public class UnlikeAjaxPage extends JsonPage { * Creates a new “unlike post” AJAX page. * * @param webInterface + * The Sone web interface */ public UnlikeAjaxPage(WebInterface webInterface) { - super("ajax/unlike.ajax", webInterface); + super("unlike.ajax", webInterface); } /** @@ -46,20 +47,22 @@ public class UnlikeAjaxPage extends JsonPage { String type = request.getHttpRequest().getParam("type", null); String id = request.getHttpRequest().getParam(type, null); if ((id == null) || (id.length() == 0)) { - return new JsonObject().put("success", false).put("error", "invalid-" + type + "-id"); + return createErrorJsonObject("invalid-" + type + "-id"); } Sone currentSone = getCurrentSone(request.getToadletContext()); if (currentSone == null) { - return new JsonObject().put("success", false).put("error", "auth-required"); + return createErrorJsonObject("auth-required"); } if ("post".equals(type)) { currentSone.removeLikedPostId(id); + webInterface.getCore().saveSone(currentSone); } else if ("reply".equals(type)) { currentSone.removeLikedReplyId(id); + webInterface.getCore().saveSone(currentSone); } else { - return new JsonObject().put("success", false).put("error", "invalid-type"); + return createErrorJsonObject("invalid-type"); } - return new JsonObject().put("success", true); + return createSuccessJsonObject(); } }