1 package net.pterodactylus.sone.web
3 import net.pterodactylus.sone.web.page.FreenetRequest
4 import net.pterodactylus.util.template.Template
5 import net.pterodactylus.util.template.TemplateContext
6 import net.pterodactylus.util.web.Method.POST
9 * Page that lets the user bookmark a post.
11 class BookmarkPage(template: Template, webInterface: WebInterface)
12 : SoneTemplatePage("bookmark.html", template, "Page.Bookmark.Title", webInterface) {
14 override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
15 if (freenetRequest.method == POST) {
16 val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
17 val postId = freenetRequest.httpRequest.getPartAsStringFailsafe("post", 36)
18 webInterface.core.getPost(postId).orNull()?.let {
19 webInterface.core.bookmarkPost(it)
21 throw RedirectException(returnPage)