X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteReplyPage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteReplyPage.kt;h=f9c51a356e957a561e2b2347d68df963ce02eb2f;hp=0000000000000000000000000000000000000000;hb=de7568a82eb4150bf6d2b0553841b7b69f84c968;hpb=9acbc5bdec4ccb752e0856a501568b0bb6161579 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt new file mode 100644 index 0000000..f9c51a3 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt @@ -0,0 +1,36 @@ +package net.pterodactylus.sone.web.pages + +import net.pterodactylus.sone.utils.isPOST +import net.pterodactylus.sone.web.pages.SoneTemplatePage +import net.pterodactylus.sone.web.WebInterface +import net.pterodactylus.sone.web.page.FreenetRequest +import net.pterodactylus.util.template.Template +import net.pterodactylus.util.template.TemplateContext + +/** + * This page lets the user delete a reply. + */ +class DeleteReplyPage(template: Template, webInterface: WebInterface): + SoneTemplatePage("deleteReply.html", template, "Page.DeleteReply.Title", webInterface, true) { + + override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { + val replyId = request.httpRequest.getPartAsStringFailsafe("reply", 36) + templateContext["reply"] = replyId + val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256) + templateContext["returnPage"] = returnPage + if (request.isPOST) { + val reply = webInterface.core.getPostReply(replyId).orNull() ?: throw RedirectException("noPermission.html") + if (!reply.sone.isLocal) { + throw RedirectException("noPermission.html") + } + if (request.httpRequest.isPartSet("confirmDelete")) { + webInterface.core.deleteReply(reply) + throw RedirectException(returnPage) + } + if (request.httpRequest.isPartSet("abortDelete")) { + throw RedirectException(returnPage) + } + } + } + +}