1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.utils.isPOST
4 import net.pterodactylus.sone.web.WebInterface
5 import net.pterodactylus.sone.web.page.FreenetRequest
6 import net.pterodactylus.util.template.Template
7 import net.pterodactylus.util.template.TemplateContext
10 * This page lets the user follow another Sone.
12 class FollowSonePage(template: Template, webInterface: WebInterface):
13 SoneTemplatePage("followSone.html", template, "Page.FollowSone.Title", webInterface, true) {
15 override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
17 request.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+"))
18 .map { it to webInterface.core.getSone(it) }
19 .filter { it.second.isPresent }
20 .map { it.first to it.second.get() }
22 webInterface.core.followSone(request.currentSone, sone.first)
23 webInterface.core.markSoneKnown(sone.second)
25 throw RedirectException(request.httpRequest.getPartAsStringFailsafe("returnPage", 256))
29 private val FreenetRequest.currentSone get() = sessionProvider.getCurrentSone(toadletContext)