X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnlikeAjaxPage.java;h=1841806bcb726ab4e84cfc855e3fdb3536b52549;hb=45f92ec63dbf8134d92ceed67294faa38117b195;hp=c062274751ea908c16222f0d54b77f8473ef1b6a;hpb=6d03f5c6dd349e47f4714e03a86c5520679118e8;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 c062274..1841806 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java @@ -20,6 +20,7 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.WebInterface; +import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; /** @@ -36,31 +37,33 @@ public class UnlikeAjaxPage extends JsonPage { * The Sone web interface */ public UnlikeAjaxPage(WebInterface webInterface) { - super("ajax/unlike.ajax", webInterface); + super("unlike.ajax", webInterface); } /** * {@inheritDoc} */ @Override - protected JsonObject createJsonObject(Request request) { + protected JsonObject createJsonObject(FreenetRequest request) { 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(); } }