X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteReplyPage.kt;h=d524c0e02ccf7c8a3cc6da3aa17570619fb770d3;hb=79b7e5bbbf68e66ccaf82f6cd4004f387f4e83fe;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..d524c0e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt @@ -1,36 +1,40 @@ 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 import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject /** * This page lets the user delete a reply. */ -class DeleteReplyPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("deleteReply.html", template, "Page.DeleteReply.Title", webInterface, true) { +class DeleteReplyPage @Inject constructor(template: Template, webInterface: WebInterface): + 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") } }