🚧 Change rescheduling method
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / ajax / UnbookmarkAjaxPage.kt
1 package net.pterodactylus.sone.web.ajax
2
3 import net.pterodactylus.sone.utils.parameters
4 import net.pterodactylus.sone.web.WebInterface
5 import net.pterodactylus.sone.web.page.*
6 import javax.inject.Inject
7
8 /**
9  * AJAX page that lets the user unbookmark a post.
10  */
11 @ToadletPath("unbookmark.ajax")
12 class UnbookmarkAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
13
14         override val requiresLogin = false
15
16         override fun createJsonObject(request: FreenetRequest) =
17                         request.parameters["post"]
18                                         ?.let(core::getPost)
19                                         ?.also(core::unbookmarkPost)
20                                         ?.let { createSuccessJsonObject() }
21                                         ?: createErrorJsonObject("invalid-post-id")
22
23 }