1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.main.*
5 import net.pterodactylus.sone.utils.isPOST
6 import net.pterodactylus.sone.utils.parameters
7 import net.pterodactylus.sone.web.WebInterface
8 import net.pterodactylus.sone.web.page.*
9 import net.pterodactylus.util.template.TemplateContext
10 import javax.inject.Inject
13 * Page that lets the user unlike a [net.pterodactylus.sone.data.Post] or [net.pterodactylus.sone.data.Reply].
15 class UnlikePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
16 LoggedInPage("unlike.html", "Page.Unlike.Title", webInterface, loaders, templateRenderer) {
18 override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
19 if (soneRequest.isPOST) {
20 when (soneRequest.parameters["type"]) {
21 "post" -> currentSone.removeLikedPostId(soneRequest.parameters["post"]!!)
22 "reply" -> currentSone.removeLikedReplyId(soneRequest.parameters["reply"]!!)
24 throw RedirectException(soneRequest.parameters["returnPage", 256])