Replace upload image page with Kotlin version
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / UnlockSonePage.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.utils.isPOST
4 import net.pterodactylus.sone.utils.parameters
5 import net.pterodactylus.sone.web.WebInterface
6 import net.pterodactylus.sone.web.page.FreenetRequest
7 import net.pterodactylus.util.template.Template
8 import net.pterodactylus.util.template.TemplateContext
9
10 /**
11  * This page lets the user unlock a [net.pterodactylus.sone.data.Sone] to allow its insertion.
12  */
13 class UnlockSonePage(template: Template, webInterface: WebInterface):
14                 SoneTemplatePage("unlockSone.html", template, "Page.UnlockSone.Title", webInterface, false) {
15
16         override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
17                 if (request.isPOST) {
18                         request.parameters["sone", 44]
19                                         .let(webInterface.core::getLocalSone)
20                                         ?.also(webInterface.core::unlockSone)
21                         throw RedirectException(request.parameters["returnPage", 256])
22                 }
23         }
24
25 }