projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
🚧 Add handler for “new Sone found” event
[Sone.git]
/
src
/
main
/
kotlin
/
net
/
pterodactylus
/
sone
/
web
/
ajax
/
UnlockSoneAjaxPage.kt
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
index
2dffbed
..
130d102
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
@@
-2,20
+2,22
@@
package net.pterodactylus.sone.web.ajax
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
+import javax.inject.Inject
/**
* Lets the user [unlock][net.pterodactylus.sone.core.Core.unlockSone] a [Sone][net.pterodactylus.sone.data.Sone].
*/
/**
* Lets the user [unlock][net.pterodactylus.sone.core.Core.unlockSone] a [Sone][net.pterodactylus.sone.data.Sone].
*/
-class UnlockSoneAjaxPage(webInterface: WebInterface) : JsonPage("unlockSone.ajax", webInterface) {
+@ToadletPath("unlockSone.ajax")
+class UnlockSoneAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
- override
fun requiresLogin()
= false
+ override
val requiresLogin
= false
override fun createJsonObject(request: FreenetRequest) =
request.parameters["sone"]
override fun createJsonObject(request: FreenetRequest) =
request.parameters["sone"]
- ?.let(
webInterface.
core::getLocalSone)
- ?.also(
webInterface.
core::unlockSone)
- ?.also {
webInterface.
core.touchConfiguration() }
+ ?.let(core::getLocalSone)
+ ?.also(core::unlockSone)
+ ?.also { core.touchConfiguration() }
?.let { createSuccessJsonObject() }
?: createErrorJsonObject("invalid-sone-id")
?.let { createSuccessJsonObject() }
?: createErrorJsonObject("invalid-sone-id")