X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FFollowSonePage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FFollowSonePage.kt;h=cf5bcee46bba83d4bd686b036b8e3f21ff55316d;hp=5069d16a9995c21b990e345641a108e358a1f3f3;hb=74cbe983cd38da24847e6247ac595cb70d8e115b;hpb=88ed72c4e8971a1d6e93a889f6774338d53682c6 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt index 5069d16..cf5bcee 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt @@ -1,5 +1,6 @@ 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 @@ -10,21 +11,19 @@ import net.pterodactylus.util.template.TemplateContext * This page lets the user follow another Sone. */ class FollowSonePage(template: Template, webInterface: WebInterface): - SoneTemplatePage("followSone.html", template, "Page.FollowSone.Title", webInterface, true) { + LoggedInPage("followSone.html", template, "Page.FollowSone.Title", webInterface) { - override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+")) .map { it to webInterface.core.getSone(it) } .filterNot { it.second == null } .forEach { sone -> - webInterface.core.followSone(freenetRequest.currentSone, sone.first) + webInterface.core.followSone(currentSone, sone.first) webInterface.core.markSoneKnown(sone.second) } throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)) } } - private val FreenetRequest.currentSone get() = sessionProvider.getCurrentSone(toadletContext) - }