1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.utils.isPOST
5 import net.pterodactylus.sone.web.WebInterface
6 import net.pterodactylus.sone.web.page.FreenetRequest
7 import net.pterodactylus.util.template.Template
8 import net.pterodactylus.util.template.TemplateContext
9 import javax.inject.Inject
12 * Page that lets the user distrust another Sone. This will assign a
13 * configurable (negative) amount of trust to an identity.
15 * @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone)
17 class DistrustPage @Inject constructor(template: Template, webInterface: WebInterface):
18 LoggedInPage("distrust.html", template, "Page.Distrust.Title", webInterface) {
20 override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
21 if (freenetRequest.isPOST) {
22 webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 44))
23 ?.run { webInterface.core.distrustSone(currentSone, this) }
24 throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))