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 unbookmark a post.
13 class UnbookmarkPage @Inject constructor(template: Template, webInterface: WebInterface):
14 SoneTemplatePage("unbookmark.html", webInterface, template, "Page.Unbookmark.Title") {
16 override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
18 freenetRequest.isGET && (freenetRequest.parameters["post"] == "allNotLoaded") -> {
19 webInterface.core.bookmarkedPosts
20 .filterNot(Post::isLoaded)
21 .forEach(webInterface.core::unbookmarkPost)
22 throw RedirectException("bookmarks.html")
24 freenetRequest.isPOST -> {
25 freenetRequest.parameters["post", 36]
26 ?.let(webInterface.core::getPost)
27 ?.also(webInterface.core::unbookmarkPost)
28 throw RedirectException(freenetRequest.parameters["returnPage", 256])