X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FUploadImagePage.kt;h=4aa35ac33a647c77736f5a4612e71240f51c74c0;hp=782c90df809f65bf0dc0703a3fdff68e939374f7;hb=74cbe983cd38da24847e6247ac595cb70d8e115b;hpb=88ed72c4e8971a1d6e93a889f6774338d53682c6 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt index 782c90d..4aa35ac 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt @@ -1,6 +1,7 @@ package net.pterodactylus.sone.web.pages import freenet.support.api.Bucket +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.text.TextFilter import net.pterodactylus.sone.utils.emptyToNull import net.pterodactylus.sone.utils.headers @@ -20,12 +21,12 @@ import javax.imageio.ImageIO * Page implementation that lets the user upload an image. */ class UploadImagePage(template: Template, webInterface: WebInterface): - SoneTemplatePage("uploadImage.html", template, "Page.UploadImage.Title", webInterface, true) { + LoggedInPage("uploadImage.html", template, "Page.UploadImage.Title", webInterface) { - override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { val parentAlbum = freenetRequest.parameters["parent"]!!.let(webInterface.core::getAlbum) ?: throw RedirectException("noPermission.html") - if (parentAlbum.sone != getCurrentSone(freenetRequest.toadletContext)) { + if (parentAlbum.sone != currentSone) { throw RedirectException("noPermission.html") } val title = freenetRequest.parameters["title", 200].emptyToNull ?: throw RedirectException("emptyImageTitle.html") @@ -39,7 +40,7 @@ class UploadImagePage(template: Template, webInterface: WebInterface): } val temporaryImage = webInterface.core.createTemporaryImage(bytes.mimeType, bytes) - webInterface.core.createImage(getCurrentSone(freenetRequest.toadletContext), parentAlbum, temporaryImage).modify().apply { + webInterface.core.createImage(currentSone, parentAlbum, temporaryImage).modify().apply { setWidth(bufferedImage.width) setHeight(bufferedImage.height) setTitle(title)