1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.utils.isPOST
4 import net.pterodactylus.sone.web.WebInterface
5 import net.pterodactylus.sone.web.page.*
6 import net.pterodactylus.util.template.Template
7 import net.pterodactylus.util.template.TemplateContext
8 import javax.inject.Inject
11 * Page that lets the user bookmark a post.
13 class BookmarkPage @Inject constructor(template: Template, webInterface: WebInterface)
14 : SoneTemplatePage("bookmark.html", webInterface, template, "Page.Bookmark.Title") {
16 override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
17 if (soneRequest.isPOST) {
18 val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
19 val postId = soneRequest.httpRequest.getPartAsStringFailsafe("post", 36)
20 soneRequest.core.getPost(postId)?.let {
21 soneRequest.core.bookmarkPost(it)
23 throw RedirectException(returnPage)