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