1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.utils.*
5 import net.pterodactylus.sone.web.*
6 import net.pterodactylus.sone.web.page.*
10 * AJAX page that lets the user trust a Sone.
12 * @see net.pterodactylus.sone.core.Core.trustSone
14 class TrustAjaxPage @Inject constructor(webInterface: WebInterface) :
15 LoggedInJsonPage("trustSone.ajax", webInterface) {
17 override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
18 request.parameters["sone"]
20 ?.let { core.trustSone(currentSone, it) }
21 ?.let { createSuccessJsonObject().put("trustValue", core.preferences.positiveTrust) }
22 ?: createErrorJsonObject("invalid-sone-id")