Add test for DI constructability of DeleteProfileFieldPage
[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.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
10 /**
11  * Page that lets the user distrust another Sone. This will assign a
12  * configurable (negative) amount of trust to an identity.
13  *
14  * @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone)
15  */
16 class DistrustPage(template: Template, webInterface: WebInterface):
17                 LoggedInPage("distrust.html", template, "Page.Distrust.Title", webInterface) {
18
19         override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
20                 if (freenetRequest.isPOST) {
21                         webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 44))
22                                         ?.run { webInterface.core.distrustSone(currentSone, this) }
23                         throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))
24                 }
25         }
26
27 }