⏪ Revert all changes to the rescue system
[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.main.*
4 import net.pterodactylus.sone.web.*
5 import net.pterodactylus.sone.web.page.*
6 import net.pterodactylus.util.template.*
7 import javax.inject.*
8
9 /**
10  * Page that lets the user dismiss a notification.
11  */
12 @ToadletPath("dismissNotification.html")
13 class DismissNotificationPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
14                 SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.DismissNotification.Title") {
15
16         override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
17                 val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
18                 val notificationId = soneRequest.httpRequest.getPartAsStringFailsafe("notification", 36)
19                 soneRequest.webInterface.getNotification(notificationId).orNull()?.takeIf { it.isDismissable }?.dismiss()
20                 redirectTo(returnPage)
21         }
22
23 }