X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnbookmarkAjaxPage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnbookmarkAjaxPage.kt;h=09a9a8838081c065dbd4777a431d30cd2fa2854a;hp=0000000000000000000000000000000000000000;hb=2cae21104ac3a7a53e2dafc92e0fefddb43fe41f;hpb=21dedb25f4c512799fa35cb60581611bb2c92716 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt new file mode 100644 index 0000000..09a9a88 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt @@ -0,0 +1,23 @@ +package net.pterodactylus.sone.web.ajax + +import net.pterodactylus.sone.utils.also +import net.pterodactylus.sone.utils.let +import net.pterodactylus.sone.utils.parameters +import net.pterodactylus.sone.web.WebInterface +import net.pterodactylus.sone.web.page.FreenetRequest + +/** + * AJAX page that lets the user unbookmark a post. + */ +class UnbookmarkAjaxPage(webInterface: WebInterface) : JsonPage("unbookmark.ajax", webInterface) { + + override fun requiresLogin() = false + + override fun createJsonObject(request: FreenetRequest) = + request.parameters["post"] + ?.let(webInterface.core::getPost) + ?.also(webInterface.core::unbookmarkPost) + ?.let { createSuccessJsonObject() } + ?: createErrorJsonObject("invalid-post-id") + +}