X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FDeletePostAjaxPage.java;h=479e71e04ace425d17365f166160e80e4c98a375;hb=6db033602e7c17efc40a4a19efe705d67832fc1a;hp=4389e577f3f38a07965f170aa4a48fa08c5e9e83;hpb=bd2cbb229f68fb2535cf6010befa9c4a276d2ee6;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java index 4389e57..479e71e 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java @@ -36,7 +36,7 @@ public class DeletePostAjaxPage extends JsonPage { * The Sone web interface */ public DeletePostAjaxPage(WebInterface webInterface) { - super("ajax/deletePost.ajax", webInterface); + super("deletePost.ajax", webInterface); } // @@ -49,19 +49,19 @@ public class DeletePostAjaxPage extends JsonPage { @Override protected JsonObject createJsonObject(Request request) { String postId = request.getHttpRequest().getParam("post"); - Post post = webInterface.getCore().getPost(postId); + Post post = webInterface.getCore().getPost(postId, false); Sone currentSone = getCurrentSone(request.getToadletContext()); - if (post == null) { - return new JsonObject().put("success", false).put("error", "invalid-post-id"); + if ((post == null) || (post.getSone() == null)) { + return createErrorJsonObject("invalid-post-id"); } if (currentSone == null) { - return new JsonObject().put("success", false).put("error", "auth-required"); + return createErrorJsonObject("auth-required"); } if (!post.getSone().equals(currentSone)) { - return new JsonObject().put("success", false).put("error", "not-authorized"); + return createErrorJsonObject("not-authorized"); } - currentSone.removePost(post); - return new JsonObject().put("success", true); + webInterface.getCore().deletePost(post); + return createSuccessJsonObject(); } }