ce5aaec05d366a2435df9c2c916dc0bcb6787ffb
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / DistrustPage.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.utils.isPOST
4 import net.pterodactylus.sone.web.WebInterface
5 import net.pterodactylus.sone.web.page.FreenetRequest
6 import net.pterodactylus.util.template.Template
7 import net.pterodactylus.util.template.TemplateContext
8
9 /**
10  * Page that lets the user distrust another Sone. This will assign a
11  * configurable (negative) amount of trust to an identity.
12  *
13  * @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone)
14  */
15 class DistrustPage(template: Template, webInterface: WebInterface):
16                 SoneTemplatePage("distrust.html", template, "Page.Distrust.Title", webInterface, true) {
17
18         override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
19                 if (freenetRequest.isPOST) {
20                         val sone = webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 44)).orNull()
21                         sone?.run { webInterface.core.distrustSone(getCurrentSone(freenetRequest.toadletContext), this) }
22                         throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))
23                 }
24         }
25
26 }