X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeletePostPage.kt;h=028ebb3dd769a797ff07cff6840604b4d190d0e0;hp=b2014f005705241242d94db320d4936035919090;hb=110a933c2724aba6a604fc5eed6372ff1e1e6144;hpb=c404ab209095a5ab96e203f83bee757ff458f349 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeletePostPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeletePostPage.kt index b2014f0..028ebb3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeletePostPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeletePostPage.kt @@ -1,38 +1,39 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.main.* import net.pterodactylus.sone.utils.isPOST import net.pterodactylus.sone.web.WebInterface -import net.pterodactylus.sone.web.page.FreenetRequest -import net.pterodactylus.util.template.Template +import net.pterodactylus.sone.web.page.* import net.pterodactylus.util.template.TemplateContext import javax.inject.Inject /** * Lets the user delete a post they made. */ -class DeletePostPage @Inject constructor(template: Template, webInterface: WebInterface): - LoggedInPage("deletePost.html", template, "Page.DeletePost.Title", webInterface) { +@TemplatePath("/templates/deletePost.html") +class DeletePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer): + LoggedInPage("deletePost.html", "Page.DeletePost.Title", webInterface, loaders, templateRenderer) { - override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { - if (freenetRequest.isPOST) { - val post = webInterface.core.getPost(freenetRequest.httpRequest.getPartAsStringFailsafe("post", 36)) ?: throw RedirectException("noPermission.html") - val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) + override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { + if (soneRequest.isPOST) { + val post = soneRequest.core.getPost(soneRequest.httpRequest.getPartAsStringFailsafe("post", 36)) ?: throw RedirectException("noPermission.html") + val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) if (!post.sone.isLocal) { throw RedirectException("noPermission.html") } - if (freenetRequest.httpRequest.isPartSet("confirmDelete")) { - webInterface.core.deletePost(post) + if (soneRequest.httpRequest.isPartSet("confirmDelete")) { + soneRequest.core.deletePost(post) throw RedirectException(returnPage) - } else if (freenetRequest.httpRequest.isPartSet("abortDelete")) { + } else if (soneRequest.httpRequest.isPartSet("abortDelete")) { throw RedirectException(returnPage) } templateContext["post"] = post templateContext["returnPage"] = returnPage return } - templateContext["post"] = webInterface.core.getPost(freenetRequest.httpRequest.getParam("post")) ?: throw RedirectException("noPermission.html") - templateContext["returnPage"] = freenetRequest.httpRequest.getParam("returnPage") + templateContext["post"] = soneRequest.core.getPost(soneRequest.httpRequest.getParam("post")) ?: throw RedirectException("noPermission.html") + templateContext["returnPage"] = soneRequest.httpRequest.getParam("returnPage") } }