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(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
16 if (freenetRequest.isPOST) {
17 val replyId = freenetRequest.httpRequest.getPartAsStringFailsafe("reply", 36)
18 val reply = webInterface.core.getPostReply(replyId) ?: throw RedirectException("noPermission.html")
19 if (!reply.sone.isLocal) {
20 throw RedirectException("noPermission.html")
22 val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
23 if (freenetRequest.httpRequest.isPartSet("confirmDelete")) {
24 webInterface.core.deleteReply(reply)
25 throw RedirectException(returnPage)
27 if (freenetRequest.httpRequest.isPartSet("abortDelete")) {
28 throw RedirectException(returnPage)
30 templateContext["reply"] = replyId
31 templateContext["returnPage"] = returnPage
34 templateContext["reply"] = freenetRequest.httpRequest.getParam("reply")
35 templateContext["returnPage"] = freenetRequest.httpRequest.getParam("returnPage")