X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteAlbumPage.kt;h=98eea86ceb6cd59a9b9acdd7dd355cb3877230fa;hp=9e6bf386e74a77f6c830b665c68c1406c7a429e8;hb=3cb0e2c78bb37f2d70ecde92ad4fcf642de788a3;hpb=de7568a82eb4150bf6d2b0553841b7b69f84c968 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt index 9e6bf38..98eea86 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt @@ -1,7 +1,6 @@ package net.pterodactylus.sone.web.pages 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 @@ -13,19 +12,20 @@ import net.pterodactylus.util.template.TemplateContext class DeleteAlbumPage(template: Template, webInterface: WebInterface): SoneTemplatePage("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - val album = webInterface.core.getAlbum(request.httpRequest.getPartAsStringFailsafe("album", 36)) - templateContext["album"] = album ?: throw RedirectException("invalid.html") - if (request.isPOST) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") if (!album.sone.isLocal) { throw RedirectException("noPermission.html") } - if (request.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") { + if (freenetRequest.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") { throw RedirectException("imageBrowser.html?album=${album.id}") } webInterface.core.deleteAlbum(album) throw RedirectException(if (album.parent.isRoot) "imageBrowser.html?sone=${album.sone.id}" else "imageBrowser.html?album=${album.parent.id}") } + val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getParam("album")) + templateContext["album"] = album ?: throw RedirectException("invalid.html") } }