X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnfollowSoneAjaxPage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnfollowSoneAjaxPage.kt;h=229765d2dbce6cdfed4a0264433f524c6decc0bb;hb=041a849c146bb1aa8980f97f3c2adb6653b6f8ca;hp=0000000000000000000000000000000000000000;hpb=0906276a29e2b5bc8ebe689ee0bdb52199186cc2;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.kt new file mode 100644 index 0000000..229765d --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.kt @@ -0,0 +1,20 @@ +package net.pterodactylus.sone.web.ajax + +import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.utils.parameters +import net.pterodactylus.sone.web.WebInterface +import net.pterodactylus.sone.web.page.FreenetRequest + +/** + * AJAX page that lets a Sone unfollow another Sone. + */ +class UnfollowSoneAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("unfollowSone.ajax", webInterface) { + + override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = + request.parameters["sone"] + ?.takeIf { webInterface.core.getSone(it).isPresent } + ?.also { webInterface.core.unfollowSone(currentSone, it) } + ?.let { createSuccessJsonObject() } + ?: createErrorJsonObject("invalid-sone-id") + +}