X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FDeletePostPage.java;h=18262a21eb160f90c8712cabbbcd8c48dd4f70e0;hb=a2715f410c410e95397ebbfabbe51a5abfd50387;hp=ea8aeffbee3cd9bcff9889a98833896859edb869;hpb=63bd3117470b16325bd808b1b68d5d922a0fe156;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java index ea8aeff..18262a2 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java @@ -51,20 +51,29 @@ public class DeletePostPage extends SoneTemplatePage { @Override protected void processTemplate(Request request, Template template) throws RedirectException { super.processTemplate(request, template); - String postId = request.getHttpRequest().getParam("post", null); - if (postId == null) { - postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36); - } - Post post = webInterface.core().getPost(postId); - Sone currentSone = getCurrentSone(request.getToadletContext()); - if (!post.getSone().equals(currentSone)) { - throw new RedirectException("noPermission.html"); - } - if (request.getMethod() == Method.POST) { + if (request.getMethod() == Method.GET) { + String postId = request.getHttpRequest().getParam("post"); + String returnPage = request.getHttpRequest().getParam("returnPage"); + Post post = webInterface.core().getPost(postId); + template.set("post", post); + template.set("returnPage", returnPage); + return; + } else if (request.getMethod() == Method.POST) { + String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36); + String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64); + Post post = webInterface.core().getPost(postId); + Sone currentSone = getCurrentSone(request.getToadletContext()); + if (!post.getSone().equals(currentSone)) { + throw new RedirectException("noPermission.html"); + } if (request.getHttpRequest().isPartSet("confirmDelete")) { currentSone.removePost(post); + throw new RedirectException(returnPage); + } else if (request.getHttpRequest().isPartSet("abortDelete")) { + throw new RedirectException(returnPage); } - throw new RedirectException("index.html"); + template.set("post", post); + template.set("returnPage", returnPage); } }