1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.utils.parameters
4 import net.pterodactylus.sone.web.WebInterface
5 import net.pterodactylus.sone.web.page.FreenetRequest
8 * Lets the user [unlock][net.pterodactylus.sone.core.Core.unlockSone] a [Sone][net.pterodactylus.sone.data.Sone].
10 class UnlockSoneAjaxPage(webInterface: WebInterface) : JsonPage("unlockSone.ajax", webInterface) {
12 override val requiresLogin = false
14 override fun createJsonObject(request: FreenetRequest) =
15 request.parameters["sone"]
16 ?.let(core::getLocalSone)
17 ?.also(core::unlockSone)
18 ?.also { core.touchConfiguration() }
19 ?.let { createSuccessJsonObject() }
20 ?: createErrorJsonObject("invalid-sone-id")