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.*
6 import javax.inject.Inject
9 * Lets the user [unlock][net.pterodactylus.sone.core.Core.unlockSone] a [Sone][net.pterodactylus.sone.data.Sone].
11 @ToadletPath("unlockSone.ajax")
12 class UnlockSoneAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
14 override val requiresLogin = false
16 override fun createJsonObject(request: FreenetRequest) =
17 request.parameters["sone"]
18 ?.let(core::getLocalSone)
19 ?.also(core::unlockSone)
20 ?.also { core.touchConfiguration() }
21 ?.let { createSuccessJsonObject() }
22 ?: createErrorJsonObject("invalid-sone-id")