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.utils.parameters
6 import net.pterodactylus.sone.web.WebInterface
7 import net.pterodactylus.sone.web.page.FreenetRequest
8 import net.pterodactylus.util.template.Template
9 import net.pterodactylus.util.template.TemplateContext
10 import javax.inject.Inject
13 * Page that lets the user control the rescue mode for a Sone.
15 class RescuePage @Inject constructor(template: Template, webInterface: WebInterface):
16 LoggedInPage("rescue.html", template, "Page.Rescue.Title", webInterface) {
18 override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
19 val soneRescuer = webInterface.core.getSoneRescuer(currentSone)
20 templateContext["soneRescuer"] = soneRescuer
21 if (freenetRequest.isPOST) {
22 freenetRequest.parameters["edition", 9]?.toIntOrNull()?.also {
24 soneRescuer.setEdition(it.toLong())
27 if (freenetRequest.parameters["fetch", 8] == "true") {
28 soneRescuer.startNextFetch()
30 throw RedirectException("rescue.html")