X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FDistrustAjaxPage.kt;h=1c3506b9f078ce6c30ab108338372dc22080caf2;hp=0c56341efcfd624f462d249d812d887874e9137c;hb=9e697ac643d11a2b7644a948732674eea195718a;hpb=e4969210bb1c68af8dc434478440516a81d91c6d diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt index 0c56341..1c3506b 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt @@ -1,6 +1,7 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.core.Core +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.let import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface @@ -11,16 +12,16 @@ import net.pterodactylus.sone.web.page.FreenetRequest * * @see Core.distrustSone(Sone, Sone) */ -class DistrustAjaxPage(webInterface: WebInterface) : JsonPage("distrustSone.ajax", webInterface) { +class DistrustAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("distrustSone.ajax", webInterface) { - override fun createJsonObject(request: FreenetRequest) = + override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] .let(webInterface.core::getSone) ?.let { sone -> createSuccessJsonObject() .put("trustValue", webInterface.core.preferences.negativeTrust) .also { - webInterface.core.distrustSone(getCurrentSone(request.toadletContext), sone) + webInterface.core.distrustSone(currentSone, sone) } } ?: createErrorJsonObject("invalid-sone-id")