1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.utils.*
5 import net.pterodactylus.sone.web.*
6 import net.pterodactylus.sone.web.page.*
7 import net.pterodactylus.util.template.*
11 * Page that lets the user mark a number of [net.pterodactylus.sone.data.Sone]s, [Post]s, or
12 * [Replie][net.pterodactylus.sone.data.Reply]s as known.
14 class MarkAsKnownPage @Inject constructor(template: Template, webInterface: WebInterface):
15 SoneTemplatePage("markAsKnown.html", webInterface, template, "Page.MarkAsKnown.Title") {
17 override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
18 val ids = soneRequest.parameters["id", 65536]!!.split(" ")
19 when (soneRequest.parameters["type", 5]) {
20 "sone" -> ids.mapNotNull(soneRequest.core::getSone).forEach(soneRequest.core::markSoneKnown)
21 "post" -> ids.mapNotNull(soneRequest.core::getPost).forEach(soneRequest.core::markPostKnown)
22 "reply" -> ids.mapNotNull(soneRequest.core::getPostReply).forEach(soneRequest.core::markReplyKnown)
23 else -> throw RedirectException("invalid.html")
25 throw RedirectException(soneRequest.parameters["returnPage", 256]!!)