1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.utils.isPOST
5 import net.pterodactylus.sone.web.WebInterface
6 import net.pterodactylus.sone.web.page.FreenetRequest
7 import net.pterodactylus.util.template.Template
8 import net.pterodactylus.util.template.TemplateContext
11 * This page lets the user follow another Sone.
13 class FollowSonePage(template: Template, webInterface: WebInterface):
14 LoggedInPage("followSone.html", template, "Page.FollowSone.Title", webInterface) {
16 override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
17 if (freenetRequest.isPOST) {
18 freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+"))
19 .map { it to webInterface.core.getSone(it) }
20 .filterNot { it.second == null }
22 webInterface.core.followSone(currentSone, sone.first)
23 webInterface.core.markSoneKnown(sone.second)
25 throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))