1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.utils.parameters
5 import net.pterodactylus.sone.web.WebInterface
6 import net.pterodactylus.sone.web.page.*
7 import javax.inject.Inject
10 * AJAX page that lets a Sone unfollow another Sone.
12 @ToadletPath("unfollowSone.ajax")
13 class UnfollowSoneAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
15 override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
16 request.parameters["sone"]
18 ?.also { core.unfollowSone(currentSone, it.id) }
19 ?.let { createSuccessJsonObject() }
20 ?: createErrorJsonObject("invalid-sone-id")