X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteReplyPage.kt;h=29d8c817db840fbbaf119c188222b68e4f9babc9;hb=74cbe983cd38da24847e6247ac595cb70d8e115b;hp=f9c51a356e957a561e2b2347d68df963ce02eb2f;hpb=de7568a82eb4150bf6d2b0553841b7b69f84c968;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt index f9c51a3..29d8c81 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt @@ -1,7 +1,7 @@ package net.pterodactylus.sone.web.pages +import net.pterodactylus.sone.data.Sone 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 @@ -11,26 +11,29 @@ 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) { + LoggedInPage("deleteReply.html", template, "Page.DeleteReply.Title", webInterface) { - 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") + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val replyId = freenetRequest.httpRequest.getPartAsStringFailsafe("reply", 36) + val reply = webInterface.core.getPostReply(replyId) ?: throw RedirectException("noPermission.html") if (!reply.sone.isLocal) { throw RedirectException("noPermission.html") } - if (request.httpRequest.isPartSet("confirmDelete")) { + val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) + if (freenetRequest.httpRequest.isPartSet("confirmDelete")) { webInterface.core.deleteReply(reply) throw RedirectException(returnPage) } - if (request.httpRequest.isPartSet("abortDelete")) { + if (freenetRequest.httpRequest.isPartSet("abortDelete")) { throw RedirectException(returnPage) } + templateContext["reply"] = replyId + templateContext["returnPage"] = returnPage + return } + templateContext["reply"] = freenetRequest.httpRequest.getParam("reply") + templateContext["returnPage"] = freenetRequest.httpRequest.getParam("returnPage") } }