Replace get notifications ajax page with Kotlin version
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / UntrustPage.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.utils.also
4 import net.pterodactylus.sone.utils.isPOST
5 import net.pterodactylus.sone.utils.parameters
6 import net.pterodactylus.sone.web.WebInterface
7 import net.pterodactylus.sone.web.page.FreenetRequest
8 import net.pterodactylus.util.template.Template
9 import net.pterodactylus.util.template.TemplateContext
10
11 /**
12  * Page that lets the user untrust another Sone. This will remove all trust
13  * assignments for an identity.
14  */
15 class UntrustPage(template: Template, webInterface: WebInterface):
16                 SoneTemplatePage("untrust.html", template, "Page.Untrust.Title", webInterface, true) {
17
18         override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
19                 if (request.isPOST) {
20                         getCurrentSone(request.toadletContext)!!.also { currentSone ->
21                                 request.parameters["sone", 44]
22                                                 .let(webInterface.core::getSone)
23                                                 .also { webInterface.core.untrustSone(currentSone, it) }
24                         }
25                         throw RedirectException(request.parameters["returnPage", 256])
26                 }
27         }
28
29 }