Replace get post ajax page with Kotlin version
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / DismissNotificationPage.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.web.WebInterface
4 import net.pterodactylus.sone.web.page.FreenetRequest
5 import net.pterodactylus.util.template.Template
6 import net.pterodactylus.util.template.TemplateContext
7
8 /**
9  * Page that lets the user dismiss a notification.
10  */
11 class DismissNotificationPage(template: Template, webInterface: WebInterface):
12                 SoneTemplatePage("dismissNotification.html", template, "Page.DismissNotification.Title", webInterface) {
13
14         override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
15                 val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256)
16                 val notificationId = request.httpRequest.getPartAsStringFailsafe("notification", 36)
17                 webInterface.getNotification(notificationId).orNull()?.takeIf { it.isDismissable }?.dismiss()
18                 throw RedirectException(returnPage)
19         }
20
21 }