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