X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FUploadImagePage.kt;h=4aa35ac33a647c77736f5a4612e71240f51c74c0;hb=d4d31bed957e29d50bd313ab973a034eba5a07f3;hp=577d52cc05f4bfdf3237829af9431e6f575e45c7;hpb=3cb0e2c78bb37f2d70ecde92ad4fcf642de788a3;p=Sone.git 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 577d52c..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 @@ -11,7 +12,6 @@ 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 org.bouncycastle.asn1.x500.style.RFC4519Style.title import java.awt.image.BufferedImage import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream @@ -21,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") @@ -40,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)