X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FFollowSonePage.kt;h=e9614307fbd5cfa4286e12fa35f4c9e34fe8ea3e;hb=3db634e425d3482bcf00dfd82e4b0d46785d5959;hp=cf5bcee46bba83d4bd686b036b8e3f21ff55316d;hpb=74cbe983cd38da24847e6247ac595cb70d8e115b;p=Sone.git 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 cf5bcee..e961430 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt @@ -3,26 +3,27 @@ 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.sone.web.page.* import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject /** * This page lets the user follow another Sone. */ -class FollowSonePage(template: Template, webInterface: WebInterface): +class FollowSonePage @Inject constructor(template: Template, webInterface: WebInterface): LoggedInPage("followSone.html", template, "Page.FollowSone.Title", webInterface) { - 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) } + override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { + if (soneRequest.isPOST) { + soneRequest.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+")) + .map { it to soneRequest.core.getSone(it) } .filterNot { it.second == null } .forEach { sone -> - webInterface.core.followSone(currentSone, sone.first) - webInterface.core.markSoneKnown(sone.second) + soneRequest.core.followSone(currentSone, sone.first) + soneRequest.core.markSoneKnown(sone.second) } - throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)) + throw RedirectException(soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)) } }