X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDeleteImagePage.kt;h=11efd94f6184ac217668d34bc6299d2f48549e07;hp=192cdfa552b7ee3fa503583baf5f7a03bb59b119;hb=6a3f1fede0cda5cd6ed56204aa1dd37a19813cb9;hpb=267e9e56e21e263d499b82dff43e9b018d6d70c5 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePage.kt index 192cdfa..11efd94 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePage.kt @@ -1,9 +1,10 @@ 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.sone.web.page.* import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext import javax.inject.Inject @@ -11,22 +12,22 @@ import javax.inject.Inject /** * Page that lets the user delete an {@link Image}. */ -class DeleteImagePage @Inject constructor(template: Template, webInterface: WebInterface): - LoggedInPage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface) { +class DeleteImagePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders): + LoggedInPage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface, loaders) { - override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { - if (freenetRequest.isPOST) { - val image = webInterface.core.getImage(freenetRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html") + override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { + if (soneRequest.isPOST) { + val image = soneRequest.core.getImage(soneRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html") if (!image.sone.isLocal) { throw RedirectException("noPermission.html") } - if (freenetRequest.httpRequest.isPartSet("abortDelete")) { + if (soneRequest.httpRequest.isPartSet("abortDelete")) { throw RedirectException("imageBrowser.html?image=${image.id}") } - webInterface.core.deleteImage(image) + soneRequest.core.deleteImage(image) throw RedirectException("imageBrowser.html?album=${image.album.id}") } - val image = webInterface.core.getImage(freenetRequest.httpRequest.getParam("image")) ?: throw RedirectException("invalid.html") + val image = soneRequest.core.getImage(soneRequest.httpRequest.getParam("image")) ?: throw RedirectException("invalid.html") if (!image.sone.isLocal) { throw RedirectException("noPermission.html") }