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 * This page lets the user delete a reply.
12 class DeleteReplyPage(template: Template, webInterface: WebInterface):
13 SoneTemplatePage("deleteReply.html", template, "Page.DeleteReply.Title", webInterface, true) {
15 override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
17 val replyId = request.httpRequest.getPartAsStringFailsafe("reply", 36)
18 val reply = webInterface.core.getPostReply(replyId).orNull() ?: throw RedirectException("noPermission.html")
19 if (!reply.sone.isLocal) {
20 throw RedirectException("noPermission.html")
22 val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256)
23 if (request.httpRequest.isPartSet("confirmDelete")) {
24 webInterface.core.deleteReply(reply)
25 throw RedirectException(returnPage)
27 if (request.httpRequest.isPartSet("abortDelete")) {
28 throw RedirectException(returnPage)
30 templateContext["reply"] = replyId
31 templateContext["returnPage"] = returnPage
34 templateContext["reply"] = request.httpRequest.getParam("reply")
35 templateContext["returnPage"] = request.httpRequest.getParam("returnPage")