♻️ Add freenet client interface
[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.*
4 import net.pterodactylus.sone.main.*
5 import net.pterodactylus.sone.utils.*
6 import net.pterodactylus.sone.web.*
7 import net.pterodactylus.sone.web.page.*
8 import net.pterodactylus.util.template.*
9 import javax.inject.*
10
11 /**
12  * Page that lets the user distrust another Sone. This will assign a
13  * configurable (negative) amount of trust to an identity.
14  *
15  * @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone)
16  */
17 @ToadletPath("distrust.html")
18 class DistrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
19                 LoggedInPage("Page.Distrust.Title", webInterface, loaders, templateRenderer) {
20
21         override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
22                 if (soneRequest.isPOST) {
23                         soneRequest.core.getSone(soneRequest.httpRequest.getPartAsStringFailsafe("sone", 44))
24                                         ?.run { soneRequest.core.distrustSone(currentSone, this) }
25                         redirectTo(soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))
26                 }
27         }
28
29 }