✨ Annotate EditProfilePage with MenuName
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / ajax / TrustAjaxPage.kt
1 package net.pterodactylus.sone.web.ajax
2
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.*
7 import javax.inject.*
8
9 /**
10  * AJAX page that lets the user trust a Sone.
11  *
12  * @see net.pterodactylus.sone.core.Core.trustSone
13  */
14 class TrustAjaxPage @Inject constructor(webInterface: WebInterface) :
15                 LoggedInJsonPage("trustSone.ajax", webInterface) {
16
17         override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
18                         request.parameters["sone"]
19                                         ?.let(core::getSone)
20                                         ?.let { core.trustSone(currentSone, it) }
21                                         ?.let { createSuccessJsonObject().put("trustValue", core.preferences.positiveTrust) }
22                                         ?: createErrorJsonObject("invalid-sone-id")
23
24 }