X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FLikeAjaxPage.java;h=bf87ead509e9ed7bc08913431a7e75b6a5b40bae;hb=1bc78b582ac59f2438002997f5780db4dcee0a2a;hp=fce9bf92b5750f4349bddbf7ae9611620ed2e527;hpb=16a69fdf1e4d4b7852ca8e2abdfd09470207ec6b;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java index fce9bf9..bf87ead 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java @@ -33,9 +33,10 @@ public class LikeAjaxPage extends JsonPage { * Creates a new “like post” AJAX page. * * @param webInterface + * The Sone web interface */ public LikeAjaxPage(WebInterface webInterface) { - super("ajax/like.ajax", webInterface); + super("like.ajax", webInterface); } /** @@ -46,20 +47,22 @@ public class LikeAjaxPage 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.addLikedPostId(id); + webInterface.getCore().touchConfiguration(); } else if ("reply".equals(type)) { currentSone.addLikedReplyId(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(); } }