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=ce5aaec05d366a2435df9c2c916dc0bcb6787ffb;hpb=3cb0e2c78bb37f2d70ecde92ad4fcf642de788a3;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 ce5aaec..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,13 +14,13 @@ 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(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { - val sone = webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 44)).orNull() - sone?.run { webInterface.core.distrustSone(getCurrentSone(freenetRequest.toadletContext), this) } + webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 44)) + ?.run { webInterface.core.distrustSone(currentSone, this) } throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)) } }