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 unbookmark a post.
14 @ToadletPath("unbookmark.html")
15 class UnbookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
16 SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.Unbookmark.Title") {
18 override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
20 soneRequest.isGET && (soneRequest.parameters["post"] == "allNotLoaded") -> {
21 soneRequest.core.bookmarkedPosts
22 .filterNot(Post::isLoaded)
23 .forEach(soneRequest.core::unbookmarkPost)
24 redirectTo("bookmarks.html")
26 soneRequest.isPOST -> {
27 soneRequest.parameters["post", 36]
28 ?.let(soneRequest.core::getPost)
29 ?.also(soneRequest.core::unbookmarkPost)
30 redirectTo(soneRequest.parameters["returnPage", 256])