X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FDistrustPage.kt;h=c312a70e1316878c363b2feac725a99c78288fab;hb=1fc003ab87ca2f5dd2d4215289f578b6177cd324;hp=d23d0e787817e7e915dde32eae91716ff4861fae;hpb=5ba707d40f9d2a20094aaabc21647aeec1feed46;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt index d23d0e7..c312a70 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt @@ -1,10 +1,12 @@ package net.pterodactylus.sone.web.pages +import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.isPOST import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject /** * Page that lets the user distrust another Sone. This will assign a @@ -12,14 +14,14 @@ import net.pterodactylus.util.template.TemplateContext * * @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone) */ -class DistrustPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("distrust.html", template, "Page.Distrust.Title", webInterface, true) { +class DistrustPage @Inject constructor(template: Template, webInterface: WebInterface): + LoggedInPage("distrust.html", template, "Page.Distrust.Title", webInterface) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val sone = webInterface.core.getSone(request.httpRequest.getPartAsStringFailsafe("sone", 44)).orNull() - sone?.run { webInterface.core.distrustSone(getCurrentSone(request.toadletContext), this) } - throw RedirectException(request.httpRequest.getPartAsStringFailsafe("returnPage", 256)) + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 44)) + ?.run { webInterface.core.distrustSone(currentSone, this) } + throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)) } }