♻️ Move throwing redirect exception into method
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / UnbookmarkPage.kt
index 29409b7..aa7bbf6 100644 (file)
@@ -11,8 +11,9 @@ import javax.inject.*
 /**
  * Page that lets the user unbookmark a post.
  */
-class UnbookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
-               SoneTemplatePage("unbookmark.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Unbookmark.Title") {
+@ToadletPath("unbookmark.html")
+class UnbookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+               SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.Unbookmark.Title") {
 
        override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
                when {
@@ -20,13 +21,13 @@ class UnbookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Lo
                                soneRequest.core.bookmarkedPosts
                                                .filterNot(Post::isLoaded)
                                                .forEach(soneRequest.core::unbookmarkPost)
-                               throw RedirectException("bookmarks.html")
+                               redirectTo("bookmarks.html")
                        }
                        soneRequest.isPOST -> {
                                soneRequest.parameters["post", 36]
                                                ?.let(soneRequest.core::getPost)
                                                ?.also(soneRequest.core::unbookmarkPost)
-                               throw RedirectException(soneRequest.parameters["returnPage", 256])
+                               redirectTo(soneRequest.parameters["returnPage", 256])
                        }
                }
        }