Replace Sone change detector with simple comparison helper
[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 import javax.inject.Inject
10
11 /**
12  * This page lets the user unlock a [net.pterodactylus.sone.data.Sone] to allow its insertion.
13  */
14 class UnlockSonePage @Inject constructor(template: Template, webInterface: WebInterface):
15                 SoneTemplatePage("unlockSone.html", webInterface, template, "Page.UnlockSone.Title") {
16
17         override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
18                 if (freenetRequest.isPOST) {
19                         freenetRequest.parameters["sone", 44]
20                                         .let(webInterface.core::getLocalSone)
21                                         ?.also(webInterface.core::unlockSone)
22                         throw RedirectException(freenetRequest.parameters["returnPage", 256])
23                 }
24         }
25
26 }