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 * Page that lets the user mark a number of [net.pterodactylus.sone.data.Sone]s, [Post]s, or
13 * [Replie][net.pterodactylus.sone.data.Reply]s as known.
15 @ToadletPath("markAsKnown.html")
16 class MarkAsKnownPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
17 SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.MarkAsKnown.Title") {
19 override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
20 val ids = soneRequest.parameters["id", 65536]!!.split(" ")
21 when (soneRequest.parameters["type", 5]) {
22 "sone" -> ids.mapNotNull(soneRequest.core::getSone).forEach(soneRequest.core::markSoneKnown)
23 "post" -> ids.mapNotNull(soneRequest.core::getPost).forEach(soneRequest.core::markPostKnown)
24 "reply" -> ids.mapNotNull(soneRequest.core::getPostReply).forEach(soneRequest.core::markReplyKnown)
25 else -> redirectTo("invalid.html")
27 redirectTo(soneRequest.parameters["returnPage", 256]!!)