X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FTrustAjaxPage.kt;h=ef806ebdb6086486cbaa6e175830049e6361ffba;hp=9a01af88aa9f35abd47c67e6b93ebf45d741facc;hb=ea7ad5e87074576d17b7df74365a726bd95d7665;hpb=85b7420f3492af4e5591f62ad673309a76de7e04 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt index 9a01af8..ef806eb 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt @@ -5,17 +5,19 @@ import net.pterodactylus.sone.utils.let import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest +import javax.inject.Inject /** * AJAX page that lets the user trust a Sone. * * @see net.pterodactylus.sone.core.Core.trustSone */ -class TrustAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("trustSone.ajax", webInterface) { +class TrustAjaxPage @Inject constructor(webInterface: WebInterface) : + LoggedInJsonPage("trustSone.ajax", webInterface) { override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] - .let(core::getSone) + ?.let(core::getSone) ?.let { core.trustSone(currentSone, it) } ?.let { createSuccessJsonObject().put("trustValue", core.preferences.positiveTrust) } ?: createErrorJsonObject("invalid-sone-id")