1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.core.Core
4 import net.pterodactylus.sone.data.Sone
5 import net.pterodactylus.sone.utils.let
6 import net.pterodactylus.sone.utils.parameters
7 import net.pterodactylus.sone.web.WebInterface
8 import net.pterodactylus.sone.web.page.FreenetRequest
11 * AJAX page that lets the user distrust a Sone.
13 * @see Core.distrustSone(Sone, Sone)
15 class DistrustAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("distrustSone.ajax", webInterface) {
17 override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
18 request.parameters["sone"]
19 .let(webInterface.core::getSone)
21 createSuccessJsonObject()
22 .put("trustValue", webInterface.core.preferences.negativeTrust)
24 webInterface.core.distrustSone(currentSone, sone)
26 } ?: createErrorJsonObject("invalid-sone-id")