1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.utils.isPOST
5 import net.pterodactylus.sone.utils.parameters
6 import net.pterodactylus.sone.web.WebInterface
7 import net.pterodactylus.sone.web.page.FreenetRequest
8 import net.pterodactylus.util.template.Template
9 import net.pterodactylus.util.template.TemplateContext
12 * Page that lets the user unlike a [net.pterodactylus.sone.data.Post] or [net.pterodactylus.sone.data.Reply].
14 class UnlikePage(template: Template, webInterface: WebInterface):
15 LoggedInPage("unlike.html", template, "Page.Unlike.Title", webInterface) {
17 override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
18 if (freenetRequest.isPOST) {
19 when (freenetRequest.parameters["type"]) {
20 "post" -> currentSone.removeLikedPostId(freenetRequest.parameters["post"]!!)
21 "reply" -> currentSone.removeLikedReplyId(freenetRequest.parameters["reply"]!!)
23 throw RedirectException(freenetRequest.parameters["returnPage", 256])