1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.main.*
4 import net.pterodactylus.sone.web.WebInterface
5 import net.pterodactylus.sone.web.page.*
6 import net.pterodactylus.util.template.Template
7 import net.pterodactylus.util.template.TemplateContext
8 import javax.inject.Inject
11 * Page that lets the user dismiss a notification.
13 class DismissNotificationPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
14 SoneTemplatePage("dismissNotification.html", webInterface, loaders, template = template, pageTitleKey = "Page.DismissNotification.Title") {
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 throw RedirectException(returnPage)