X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetLikesAjaxPage.java;h=83fa15ba928a5f059fb3c24b7b7c4a57f9c8094d;hp=d27d82fdb7d25f5490cc6db564a8d8ce8c2401f6;hb=a47643aed43d118ca68044f95451bb5374cdb332;hpb=bd2cbb229f68fb2535cf6010befa9c4a276d2ee6 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java index d27d82f..83fa15b 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - GetLikesAjaxPage.java - Copyright © 2010 David Roden + * Sone - GetLikesAjaxPage.java - Copyright © 2010–2012 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,10 +23,11 @@ import java.util.List; import java.util.Set; import net.pterodactylus.sone.data.Post; -import net.pterodactylus.sone.data.Reply; +import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.template.SoneAccessor; import net.pterodactylus.sone.web.WebInterface; +import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonArray; import net.pterodactylus.util.json.JsonObject; @@ -44,7 +45,7 @@ public class GetLikesAjaxPage extends JsonPage { * The Sone web interface */ public GetLikesAjaxPage(WebInterface webInterface) { - super("ajax/getLikes.ajax", webInterface); + super("getLikes.ajax", webInterface); } // @@ -55,22 +56,22 @@ public class GetLikesAjaxPage extends JsonPage { * {@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"); } if ("post".equals(type)) { Post post = webInterface.getCore().getPost(id); Set sones = webInterface.getCore().getLikes(post); - return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones)); + return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones)); } else if ("reply".equals(type)) { - Reply reply = webInterface.getCore().getReply(id); + PostReply reply = webInterface.getCore().getReply(id); Set sones = webInterface.getCore().getLikes(reply); - return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones)); + return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones)); } - return new JsonObject().put("success", false).put("error", "invalid-type"); + return createErrorJsonObject("invalid-type"); } /**