X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetLikesAjaxPage.java;h=a8b991d992ea458c1494545dbd3d3f94532ccb7a;hb=85fd1173da553ee8c1afbe0c4638cc9bbce8d44f;hp=529dd995405c3c911108f2805a8e31ac931ba76e;hpb=551692842e862abffc7d5fb63365fc835692c4f5;p=Sone.git 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 529dd99..a8b991d 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java @@ -44,7 +44,7 @@ public class GetLikesAjaxPage extends JsonPage { * The Sone web interface */ public GetLikesAjaxPage(WebInterface webInterface) { - super("ajax/getLikes.ajax", webInterface); + super("getLikes.ajax", webInterface); } // @@ -59,18 +59,18 @@ public class GetLikesAjaxPage 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"); } if ("post".equals(type)) { - Post post = webInterface.core().getPost(id); - Set sones = webInterface.core().getLikes(post); - return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones)); + Post post = webInterface.getCore().getPost(id); + Set sones = webInterface.getCore().getLikes(post); + return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones)); } else if ("reply".equals(type)) { - Reply reply = webInterface.core().getReply(id); - Set sones = webInterface.core().getLikes(reply); - return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones)); + Reply reply = webInterface.getCore().getReply(id); + Set sones = webInterface.getCore().getLikes(reply); + return createSuccessJsonObject().put("likes", sones.size()).put("sones", getSones(sones)); } - return new JsonObject().put("success", false).put("error", "invalid-type"); + return createErrorJsonObject("invalid-type"); } /**