X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FLikeAjaxPage.java;h=bf87ead509e9ed7bc08913431a7e75b6a5b40bae;hp=23a5aeca41ba98166f314106204b6bf8e5015386;hb=89a905395984ec35e313b07594e21773ffd3d9d8;hpb=6d03f5c6dd349e47f4714e03a86c5520679118e8 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 23a5aec..bf87ead 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java @@ -36,7 +36,7 @@ public class LikeAjaxPage extends JsonPage { * The Sone web interface */ public LikeAjaxPage(WebInterface webInterface) { - super("ajax/like.ajax", webInterface); + super("like.ajax", webInterface); } /** @@ -47,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(); } }