From: David ‘Bombe’ Roden Date: Tue, 18 Jan 2011 05:57:24 +0000 (+0100) Subject: Allow deletion of posts of all local Sones, not only the logged in. X-Git-Tag: 0.4.2^2~30^2~8 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=5c64637098471f7cd59fcd3f1ce873c0f394c13d;p=Sone.git Allow deletion of posts of all local Sones, not only the logged in. --- diff --git a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java index 5722ee3..78c9f22 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java @@ -18,7 +18,6 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Post; -import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.page.Page.Request.Method; import net.pterodactylus.util.template.DataProvider; import net.pterodactylus.util.template.Template; @@ -63,12 +62,11 @@ public class DeletePostPage extends SoneTemplatePage { String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36); String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); Post post = webInterface.getCore().getPost(postId); - Sone currentSone = getCurrentSone(request.getToadletContext()); - if (!post.getSone().equals(currentSone)) { + if (!webInterface.getCore().isLocalSone(post.getSone())) { throw new RedirectException("noPermission.html"); } if (request.getHttpRequest().isPartSet("confirmDelete")) { - currentSone.removePost(post); + webInterface.getCore().deletePost(post); throw new RedirectException(returnPage); } else if (request.getHttpRequest().isPartSet("abortDelete")) { throw new RedirectException(returnPage); 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 479e71e..8d3b414 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java @@ -18,7 +18,6 @@ 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.util.json.JsonObject; @@ -50,14 +49,10 @@ public class DeletePostAjaxPage extends JsonPage { protected JsonObject createJsonObject(Request request) { String postId = request.getHttpRequest().getParam("post"); Post post = webInterface.getCore().getPost(postId, false); - Sone currentSone = getCurrentSone(request.getToadletContext()); if ((post == null) || (post.getSone() == null)) { return createErrorJsonObject("invalid-post-id"); } - if (currentSone == null) { - return createErrorJsonObject("auth-required"); - } - if (!post.getSone().equals(currentSone)) { + if (!webInterface.getCore().isLocalSone(post.getSone())) { return createErrorJsonObject("not-authorized"); } webInterface.getCore().deletePost(post); diff --git a/src/main/resources/templates/include/viewPost.html b/src/main/resources/templates/include/viewPost.html index 5161dfe..b4f570f 100644 --- a/src/main/resources/templates/include/viewPost.html +++ b/src/main/resources/templates/include/viewPost.html @@ -62,7 +62,7 @@ <%/if> <%/if> - <%if post.sone.current> + <%if post.sone.local> ·
diff --git a/src/main/resources/templates/include/viewReply.html b/src/main/resources/templates/include/viewReply.html index 805626a..6b13776 100644 --- a/src/main/resources/templates/include/viewReply.html +++ b/src/main/resources/templates/include/viewReply.html @@ -54,7 +54,7 @@
<%/if> <%/if> - <%if reply.sone.current> + <%if reply.sone.local> ·