♻️ Move throwing redirect exception into method
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / LikePage.kt
index afaee6a..c8369e9 100644 (file)
@@ -1,19 +1,19 @@
 package net.pterodactylus.sone.web.pages
 
-import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.data.*
 import net.pterodactylus.sone.main.*
-import net.pterodactylus.sone.utils.isPOST
-import net.pterodactylus.sone.utils.parameters
-import net.pterodactylus.sone.web.WebInterface
+import net.pterodactylus.sone.utils.*
+import net.pterodactylus.sone.web.*
 import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.TemplateContext
-import javax.inject.Inject
+import net.pterodactylus.util.template.*
+import javax.inject.*
 
 /**
  * Page that lets the user like [net.pterodactylus.sone.data.Post]s and [net.pterodactylus.sone.data.Reply]s.
  */
+@ToadletPath("like.html")
 class LikePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
-               LoggedInPage("like.html", "Page.Like.Title", webInterface, loaders, templateRenderer) {
+               LoggedInPage("Page.Like.Title", webInterface, loaders, templateRenderer) {
 
        override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
                if (soneRequest.isPOST) {
@@ -23,7 +23,7 @@ class LikePage @Inject constructor(webInterface: WebInterface, loaders: Loaders,
                                        "reply" -> currentSone.addLikedReplyId(soneRequest.parameters["reply", 36]!!)
                                }
                        }
-                       throw RedirectException(soneRequest.parameters["returnPage", 256]!!)
+                       redirectTo(soneRequest.parameters["returnPage", 256]!!)
                }
        }