1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.utils.isPOST
4 import net.pterodactylus.sone.web.WebInterface
5 import net.pterodactylus.sone.web.page.FreenetRequest
6 import net.pterodactylus.util.template.Template
7 import net.pterodactylus.util.template.TemplateContext
10 * Lets the user delete a post they made.
12 class DeletePostPage(template: Template, webInterface: WebInterface):
13 SoneTemplatePage("deletePost.html", template, "Page.DeletePost.Title", webInterface, true) {
15 override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
17 val post = webInterface.core.getPost(request.httpRequest.getPartAsStringFailsafe("post", 36)).orNull() ?: throw RedirectException("noPermission.html")
18 val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256)
19 if (!post.sone.isLocal) {
20 throw RedirectException("noPermission.html")
22 if (request.httpRequest.isPartSet("confirmDelete")) {
23 webInterface.core.deletePost(post)
24 throw RedirectException(returnPage)
25 } else if (request.httpRequest.isPartSet("abortDelete")) {
26 throw RedirectException(returnPage)
28 templateContext["post"] = post
29 templateContext["returnPage"] = returnPage
32 templateContext["post"] = webInterface.core.getPost(request.httpRequest.getParam("post")).orNull() ?: throw RedirectException("noPermission.html")
33 templateContext["returnPage"] = request.httpRequest.getParam("returnPage")