X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnlikeAjaxPage.java;h=84b059330a87818631e3cba21e396e145c37db46;hp=a6a325abd4529dd4284475f479085ea0b73688ae;hb=89a905395984ec35e313b07594e21773ffd3d9d8;hpb=16a69fdf1e4d4b7852ca8e2abdfd09470207ec6b 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..84b0593 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().touchConfiguration(); } else if ("reply".equals(type)) { currentSone.removeLikedReplyId(id); + webInterface.getCore().touchConfiguration(); } else { - return new JsonObject().put("success", false).put("error", "invalid-type"); + return createErrorJsonObject("invalid-type"); } - return new JsonObject().put("success", true); + return createSuccessJsonObject(); } }