Update to Kotlin 1.2.0
[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.isPOST
4 import net.pterodactylus.sone.utils.parameters
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 untrust another Sone. This will remove all trust
12  * assignments for an identity.
13  */
14 class UntrustPage(template: Template, webInterface: WebInterface):
15                 SoneTemplatePage("untrust.html", template, "Page.Untrust.Title", webInterface, true) {
16
17         override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
18                 if (freenetRequest.isPOST) {
19                         getCurrentSone(freenetRequest.toadletContext)!!.also { currentSone ->
20                                 freenetRequest.parameters["sone", 44]!!
21                                                 .let(webInterface.core::getSone)
22                                                 ?.also { webInterface.core.untrustSone(currentSone, it) }
23                         }
24                         throw RedirectException(freenetRequest.parameters["returnPage", 256])
25                 }
26         }
27
28 }