1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.main.*
5 import net.pterodactylus.sone.utils.*
6 import net.pterodactylus.sone.web.*
7 import net.pterodactylus.sone.web.page.*
8 import net.pterodactylus.util.template.*
12 * This page lets the user follow another Sone.
14 @ToadletPath("followSone.html")
15 class FollowSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
16 LoggedInPage("Page.FollowSone.Title", webInterface, loaders, templateRenderer) {
18 override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
19 if (soneRequest.isPOST) {
20 soneRequest.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+"))
21 .map { it to soneRequest.core.getSone(it) }
22 .filterNot { it.second == null }
24 soneRequest.core.followSone(currentSone, sone.first)
25 soneRequest.core.markSoneKnown(sone.second)
27 redirectTo(soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))