X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FBookmarkPage.kt;h=bcff177636a4c1f33aa7ccb3ed959e5a3f4e8ed9;hb=1557106d0e373f7efc15faed65f69eb567613a45;hp=519d49ecd124611b51dd4a474b65a890058dd44c;hpb=5ba707d40f9d2a20094aaabc21647aeec1feed46;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarkPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarkPage.kt index 519d49e..bcff177 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarkPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarkPage.kt @@ -5,18 +5,19 @@ import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject /** * Page that lets the user bookmark a post. */ -class BookmarkPage(template: Template, webInterface: WebInterface) - : SoneTemplatePage("bookmark.html", template, "Page.Bookmark.Title", webInterface) { +class BookmarkPage @Inject constructor(template: Template, webInterface: WebInterface) + : SoneTemplatePage("bookmark.html", webInterface, template, "Page.Bookmark.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { if (freenetRequest.isPOST) { val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) val postId = freenetRequest.httpRequest.getPartAsStringFailsafe("post", 36) - webInterface.core.getPost(postId).orNull()?.let { + webInterface.core.getPost(postId)?.let { webInterface.core.bookmarkPost(it) } throw RedirectException(returnPage)