♻️ Move throwing redirect exception into method
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / DeletePostPage.kt
index 877a1fc..2396370 100644 (file)
@@ -12,27 +12,28 @@ import javax.inject.*
  * Lets the user delete a post they made.
  */
 @TemplatePath("/templates/deletePost.html")
+@ToadletPath("deletePost.html")
 class DeletePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
-               LoggedInPage("deletePost.html", "Page.DeletePost.Title", webInterface, loaders, templateRenderer) {
+               LoggedInPage("Page.DeletePost.Title", webInterface, loaders, templateRenderer) {
 
        override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
                if (soneRequest.isPOST) {
-                       val post = soneRequest.core.getPost(soneRequest.httpRequest.getPartAsStringFailsafe("post", 36)) ?: throw RedirectException("noPermission.html")
+                       val post = soneRequest.core.getPost(soneRequest.httpRequest.getPartAsStringFailsafe("post", 36)) ?: redirectTo("noPermission.html")
                        val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
                        if (!post.sone.isLocal) {
-                               throw RedirectException("noPermission.html")
+                               redirectTo("noPermission.html")
                        }
                        if (soneRequest.httpRequest.isPartSet("confirmDelete")) {
                                soneRequest.core.deletePost(post)
-                               throw RedirectException(returnPage)
+                               redirectTo(returnPage)
                        } else if (soneRequest.httpRequest.isPartSet("abortDelete")) {
-                               throw RedirectException(returnPage)
+                               redirectTo(returnPage)
                        }
                        templateContext["post"] = post
                        templateContext["returnPage"] = returnPage
                        return
                }
-               templateContext["post"] = soneRequest.core.getPost(soneRequest.httpRequest.getParam("post")) ?: throw RedirectException("noPermission.html")
+               templateContext["post"] = soneRequest.core.getPost(soneRequest.httpRequest.getParam("post")) ?: redirectTo("noPermission.html")
                templateContext["returnPage"] = soneRequest.httpRequest.getParam("returnPage")
        }