1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.core.Core
4 import net.pterodactylus.sone.utils.let
5 import net.pterodactylus.sone.utils.parameters
6 import net.pterodactylus.sone.web.WebInterface
7 import net.pterodactylus.sone.web.page.FreenetRequest
10 * AJAX page that lets the user distrust a Sone.
12 * @see Core.distrustSone(Sone, Sone)
14 class DistrustAjaxPage(webInterface: WebInterface) : JsonPage("distrustSone.ajax", webInterface) {
16 override fun createJsonObject(request: FreenetRequest) =
17 request.parameters["sone"]
18 .let(webInterface.core::getSone)
20 createSuccessJsonObject()
21 .put("trustValue", webInterface.core.preferences.negativeTrust)
23 webInterface.core.distrustSone(getCurrentSone(request.toadletContext), sone)
25 } ?: createErrorJsonObject("invalid-sone-id")