From 85b7420f3492af4e5591f62ad673309a76de7e04 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 5 Oct 2017 21:21:26 +0200 Subject: [PATCH] Expose core as member of JsonPage --- .../net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt | 4 ++-- .../net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt | 6 +++--- .../net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.kt | 6 +++--- .../net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.kt | 4 ++-- .../sone/web/ajax/DeleteProfileFieldAjaxPage.kt | 2 +- .../net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.kt | 4 ++-- .../net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt | 6 +++--- .../net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt | 2 +- .../net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt | 8 ++++---- .../net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.kt | 6 +++--- .../net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt | 8 ++++---- .../pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt | 12 ++++++------ .../net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt | 6 +++--- .../net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt | 4 ++-- .../net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt | 4 ++-- .../net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt | 4 ++-- src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt | 3 ++- .../kotlin/net/pterodactylus/sone/web/ajax/LikeAjaxPage.kt | 8 ++++---- .../net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt | 4 ++-- .../net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt | 6 +++--- .../pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.kt | 2 +- .../kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt | 6 +++--- .../net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt | 4 ++-- .../net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.kt | 4 ++-- .../kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt | 2 +- .../net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt | 6 +++--- .../net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt | 4 ++-- 27 files changed, 68 insertions(+), 67 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt index fd22f06..f7d3cc7 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt @@ -15,8 +15,8 @@ class BookmarkAjaxPage(webInterface: WebInterface) : JsonPage("bookmark.ajax", w override fun createJsonObject(request: FreenetRequest) = request.parameters["post"].emptyToNull - ?.let(webInterface.core::getPost) - ?.also(webInterface.core::bookmarkPost) + ?.let(core::getPost) + ?.also(core::bookmarkPost) ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-post-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt index 9e96e69..ec65b55 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt @@ -18,9 +18,9 @@ class CreatePostAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("createP request.parameters["text"].emptyToNull ?.let { TextFilter.filter(request.headers["Host"], it) } ?.let { text -> - val sender = request.parameters["sender"].emptyToNull?.let(webInterface.core::getSone)?.orNull() ?: currentSone - val recipient = request.parameters["recipient"].let(webInterface.core::getSone) - webInterface.core.createPost(sender, recipient, text).let { post -> + val sender = request.parameters["sender"].emptyToNull?.let(core::getSone)?.orNull() ?: currentSone + val recipient = request.parameters["recipient"].let(core::getSone) + core.createPost(sender, recipient, text).let { post -> createSuccessJsonObject().apply { put("postId", post.id) put("sone", sender.id) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.kt index c8f9317..f817e28 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.kt @@ -16,11 +16,11 @@ class CreateReplyAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("create override fun createJsonObject(currentSone: Sone, request: FreenetRequest): JsonReturnObject = request.parameters["post"].emptyToNull - ?.let(webInterface.core::getPost) + ?.let(core::getPost) ?.let { post -> val text = TextFilter.filter(request.headers["Host"], request.parameters["text"]) - val sender = request.parameters["sender"].let(webInterface.core::getLocalSone) ?: currentSone - val reply = webInterface.core.createReply(sender, post, text) + val sender = request.parameters["sender"].let(core::getLocalSone) ?: currentSone + val reply = core.createReply(sender, post, text) createSuccessJsonObject().apply { put("reply", reply.id) put("sone", sender.id) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.kt index 74fd796..76d867e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.kt @@ -14,11 +14,11 @@ class DeletePostAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("deleteP override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["post"] - .let(webInterface.core::getPost) + .let(core::getPost) ?.let { post -> post.sone.isLocal.ifTrue { createSuccessJsonObject().also { - webInterface.core.deletePost(post) + core.deletePost(post) } } ?: createErrorJsonObject("not-authorized") } ?: createErrorJsonObject("invalid-post-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.kt index 9595a8c..05f53da 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.kt @@ -18,7 +18,7 @@ class DeleteProfileFieldAjaxPage(webInterface: WebInterface) : LoggedInJsonPage( createSuccessJsonObject().also { profile.removeField(field) currentSone.profile = profile - webInterface.core.touchConfiguration() + core.touchConfiguration() } } ?: createErrorJsonObject("invalid-field-id") } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.kt index 010e02b..2108daf 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.kt @@ -14,11 +14,11 @@ class DeleteReplyAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("delete override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["reply"] - .let(webInterface.core::getPostReply) + .let(core::getPostReply) ?.let { reply -> reply.sone.isLocal.ifTrue { createSuccessJsonObject().also { - webInterface.core.deleteReply(reply) + core.deleteReply(reply) } } ?: createErrorJsonObject("not-authorized") } ?: createErrorJsonObject("invalid-reply-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt index 1c3506b..e4f8435 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt @@ -16,12 +16,12 @@ class DistrustAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("distrustS override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] - .let(webInterface.core::getSone) + .let(core::getSone) ?.let { sone -> createSuccessJsonObject() - .put("trustValue", webInterface.core.preferences.negativeTrust) + .put("trustValue", core.preferences.negativeTrust) .also { - webInterface.core.distrustSone(currentSone, sone) + core.distrustSone(currentSone, sone) } } ?: createErrorJsonObject("invalid-sone-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt index cf12b33..321ee7d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt @@ -14,7 +14,7 @@ class EditAlbumAjaxPage(webInterface: WebInterface) : JsonPage("editAlbum.ajax", override fun createJsonObject(request: FreenetRequest) = request.parameters["album"]!! - .let(webInterface.core::getAlbum) + .let(core::getAlbum) ?.let { album -> album.sone.isLocal.ifTrue { when { diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt index ee2cf19..dbeb2d2 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt @@ -21,19 +21,19 @@ class EditImageAjaxPage(webInterface: WebInterface, override fun createJsonObject(request: FreenetRequest) = request.parameters["image"] - .let(webInterface.core::getImage) + .let(core::getImage) ?.let { image -> image.sone.isLocal.ifTrue { when { request.parameters["moveLeft"] == "true" -> createSuccessJsonObject().apply { put("sourceImageId", image.id) put("destinationImageId", image.album.moveImageUp(image).id) - webInterface.core.touchConfiguration() + core.touchConfiguration() } request.parameters["moveRight"] == "true" -> createSuccessJsonObject().apply { put("sourceImageId", image.id) put("destinationImageId", image.album.moveImageDown(image).id) - webInterface.core.touchConfiguration() + core.touchConfiguration() } else -> request.parameters["title"]!!.let { title -> title.trim().isNotBlank().ifTrue { @@ -52,7 +52,7 @@ class EditImageAjaxPage(webInterface: WebInterface, } } }) - webInterface.core.touchConfiguration() + core.touchConfiguration() } } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.kt index b37b48a..c6aa25e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.kt @@ -14,9 +14,9 @@ class FollowSoneAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("followS override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] - .let(webInterface.core::getSone) - ?.also { webInterface.core.followSone(currentSone, it.id) } - ?.also(webInterface.core::markSoneKnown) + .let(core::getSone) + ?.also { core.followSone(currentSone, it.id) } + ?.also(core::markSoneKnown) ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-sone-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt index fc2142d..12e8309 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt @@ -20,13 +20,13 @@ class GetLikesAjaxPage(webInterface: WebInterface) : JsonPage("getLikes.ajax", w override fun createJsonObject(request: FreenetRequest) = when (request.parameters["type"]) { "post" -> request.parameters["post"] - .let(webInterface.core::getPost) - ?.let(webInterface.core::getLikes) + .let(core::getPost) + ?.let(core::getLikes) ?.toReply() ?: createErrorJsonObject("invalid-post-id") "reply" -> request.parameters["reply"] - .let(webInterface.core::getPostReply) - ?.let(webInterface.core::getLikes) + .let(core::getPostReply) + ?.let(core::getLikes) ?.toReply() ?: createErrorJsonObject("invalid-reply-id") else -> createErrorJsonObject("invalid-type") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt index d218a3d..1671d6d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt @@ -48,15 +48,15 @@ class GetNotificationsAjaxPage(webInterface: WebInterface) : JsonPage("getNotifi val mergedTemplateContext = webInterface.templateContextFactory.createTemplateContext() .mergeContext(templateContext) .apply { - this["core"] = webInterface.core + this["core"] = core this["currentSone"] = currentSone - this["localSones"] = webInterface.core.localSones + this["localSones"] = core.localSones this["request"] = freenetRequest this["currentVersion"] = SonePlugin.getPluginVersion() - this["hasLatestVersion"] = webInterface.core.updateChecker.hasLatestVersion() - this["latestEdition"] = webInterface.core.updateChecker.latestEdition - this["latestVersion"] = webInterface.core.updateChecker.latestVersion - this["latestVersionTime"] = webInterface.core.updateChecker.latestVersionDate + this["hasLatestVersion"] = core.updateChecker.hasLatestVersion() + this["latestEdition"] = core.updateChecker.latestEdition + this["latestVersion"] = core.updateChecker.latestVersion + this["latestVersionTime"] = core.updateChecker.latestVersionDate this["notification"] = this@render } it.also { render(mergedTemplateContext, it) } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt index eb8d8a0..2b1deca 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt @@ -19,7 +19,7 @@ class GetPostAjaxPage(webInterface: WebInterface, private val postTemplate: Temp override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["post"] - .let(webInterface.core::getPost) + .let(core::getPost) .let { post -> createSuccessJsonObject(). put("post", jsonObject( @@ -33,11 +33,11 @@ class GetPostAjaxPage(webInterface: WebInterface, private val postTemplate: Temp private fun Post.render(currentSone: Sone, request: FreenetRequest) = webInterface.templateContextFactory.createTemplateContext().apply { - set("core", webInterface.core) + set("core", core) set("request", request) set("post", this@render) set("currentSone", currentSone) - set("localSones", webInterface.core.localSones) + set("localSones", core.localSones) }.let { postTemplate.render(it) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt index a9709e8..332ab87 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt @@ -19,7 +19,7 @@ class GetReplyAjaxPage(webInterface: WebInterface, private val template: Templat override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["reply"] - .let(webInterface.core::getPostReply) + .let(core::getPostReply) ?.let { it.toJson(currentSone, request) } ?.let { replyJson -> createSuccessJsonObject().apply { @@ -37,7 +37,7 @@ class GetReplyAjaxPage(webInterface: WebInterface, private val template: Templat private fun PostReply.render(currentSone: Sone, request: FreenetRequest) = webInterface.templateContextFactory.createTemplateContext().apply { - set("core", webInterface.core) + set("core", core) set("request", request) set("reply", this@render) set("currentSone", currentSone) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt index e2642c9..696c65a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt @@ -64,8 +64,8 @@ class GetStatusAjaxPage(webInterface: WebInterface, private val elementLoader: E put("name", SoneAccessor.getNiceName(sone)) put("local", sone.isLocal) put("status", sone.status.name) - put("modified", webInterface.core.isModifiedSone(sone)) - put("locked", webInterface.core.isLocked(sone)) + put("modified", core.isModifiedSone(sone)) + put("locked", core.isLocked(sone)) put("lastUpdatedUnknown", sone.time == 0L) synchronized(dateFormatter) { put("lastUpdated", dateFormatter.format(sone.time)) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt index 9310786..87eafc3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt @@ -27,8 +27,8 @@ class GetTimesAjaxPage(webInterface: WebInterface, override fun createJsonObject(request: FreenetRequest) = createSuccessJsonObject().apply { - put("postTimes", request.parameters["posts"]!!.idsToJson { webInterface.core.getPost(it)?.let { it.id to it.time } }) - put("replyTimes", request.parameters["replies"]!!.idsToJson { webInterface.core.getPostReply(it)?.let { it.id to it.time } }) + put("postTimes", request.parameters["posts"]!!.idsToJson { core.getPost(it)?.let { it.id to it.time } }) + put("replyTimes", request.parameters["replies"]!!.idsToJson { core.getPostReply(it)?.let { it.id to it.time } }) } private fun String.idsToJson(transform: (String) -> Pair?) = diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt index 6ba842f..1136616 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt @@ -19,6 +19,7 @@ abstract class JsonPage(private val path: String, protected val webInterface: We private val objectMapper = ObjectMapper() private val sessionProvider: SessionProvider = webInterface + protected val core = webInterface.core override fun getPath() = path override fun isPrefixPage() = false @@ -34,7 +35,7 @@ abstract class JsonPage(private val path: String, protected val webInterface: We sessionProvider.getCurrentSone(toadletContext, createSession) override fun handleRequest(request: FreenetRequest, response: Response): Response { - if (webInterface.core.preferences.isRequireFullAccess && !request.toadletContext.isAllowedFullAccess) { + if (core.preferences.isRequireFullAccess && !request.toadletContext.isAllowedFullAccess) { return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(createErrorJsonObject("auth-required").asJsonString()) } if (needsFormPassword() && request.parameters["formPassword"] != webInterface.formPassword) { diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/LikeAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/LikeAjaxPage.kt index 3b206c8..4257725 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/LikeAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/LikeAjaxPage.kt @@ -14,15 +14,15 @@ class LikeAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("like.ajax", w override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = when (request.parameters["type"]) { "post" -> request.parameters["post"] - .let(webInterface.core::getPost) + .let(core::getPost) ?.let { currentSone.addLikedPostId(it.id) } - ?.also { webInterface.core.touchConfiguration() } + ?.also { core.touchConfiguration() } ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-post-id") "reply" -> request.parameters["reply"] - .let(webInterface.core::getPostReply) + .let(core::getPostReply) ?.let { currentSone.addLikedReplyId(it.id) } - ?.also { webInterface.core.touchConfiguration() } + ?.also { core.touchConfiguration() } ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-reply-id") else -> createErrorJsonObject("invalid-type") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt index add66b5..7b3a9b2 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt @@ -13,8 +13,8 @@ class LockSoneAjaxPage(webInterface: WebInterface) : JsonPage("lockSone.ajax", w override fun createJsonObject(request: FreenetRequest) = request.parameters["sone"] - .let(webInterface.core::getLocalSone) - ?.let(webInterface.core::lockSone) + .let(core::getLocalSone) + ?.let(core::lockSone) ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-sone-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt index beec718..8053591 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt @@ -15,9 +15,9 @@ class MarkAsKnownAjaxPage(webInterface: WebInterface) : JsonPage("markAsKnown.aj override fun requiresLogin() = false override fun createJsonObject(request: FreenetRequest) = when (request.parameters["type"]) { - "sone" -> processIds(request, webInterface.core::getSone, webInterface.core::markSoneKnown) - "post" -> processIds(request, webInterface.core::getPost, webInterface.core::markPostKnown) - "reply" -> processIds(request, webInterface.core::getPostReply, webInterface.core::markReplyKnown) + "sone" -> processIds(request, core::getSone, core::markSoneKnown) + "post" -> processIds(request, core::getPost, core::markPostKnown) + "reply" -> processIds(request, core::getPostReply, core::markReplyKnown) else -> createErrorJsonObject("invalid-type") } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.kt index e2b039b..1c050bf 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.kt @@ -31,7 +31,7 @@ class MoveProfileFieldAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("m else -> null }?.let { currentSone.profile = profile - webInterface.core.touchConfiguration() + core.touchConfiguration() createSuccessJsonObject() } ?: createErrorJsonObject("invalid-direction") } catch (e: IllegalArgumentException) { diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt index 228a0b5..9a01af8 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt @@ -15,9 +15,9 @@ class TrustAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("trustSone.aj override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] - .let(webInterface.core::getSone) - ?.let { webInterface.core.trustSone(currentSone, it) } - ?.let { createSuccessJsonObject().put("trustValue", webInterface.core.preferences.positiveTrust) } + .let(core::getSone) + ?.let { core.trustSone(currentSone, it) } + ?.let { createSuccessJsonObject().put("trustValue", core.preferences.positiveTrust) } ?: createErrorJsonObject("invalid-sone-id") } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt index 09a9a88..11b3bbf 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt @@ -15,8 +15,8 @@ class UnbookmarkAjaxPage(webInterface: WebInterface) : JsonPage("unbookmark.ajax override fun createJsonObject(request: FreenetRequest) = request.parameters["post"] - ?.let(webInterface.core::getPost) - ?.also(webInterface.core::unbookmarkPost) + ?.let(core::getPost) + ?.also(core::unbookmarkPost) ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-post-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.kt index 229765d..6889d04 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.kt @@ -12,8 +12,8 @@ class UnfollowSoneAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("unfol override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] - ?.takeIf { webInterface.core.getSone(it).isPresent } - ?.also { webInterface.core.unfollowSone(currentSone, it) } + ?.takeIf { core.getSone(it).isPresent } + ?.also { core.unfollowSone(currentSone, it) } ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-sone-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt index c4ec236..b30829a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt @@ -20,7 +20,7 @@ class UnlikeAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("unlike.ajax private fun FreenetRequest.processEntity(entity: String, likeRemover: (String) -> Unit) = parameters[entity].emptyToNull ?.also(likeRemover) - ?.also { webInterface.core.touchConfiguration() } + ?.also { core.touchConfiguration() } ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-$entity-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt index 2dffbed..18129f3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt @@ -13,9 +13,9 @@ class UnlockSoneAjaxPage(webInterface: WebInterface) : JsonPage("unlockSone.ajax override fun createJsonObject(request: FreenetRequest) = request.parameters["sone"] - ?.let(webInterface.core::getLocalSone) - ?.also(webInterface.core::unlockSone) - ?.also { webInterface.core.touchConfiguration() } + ?.let(core::getLocalSone) + ?.also(core::unlockSone) + ?.also { core.touchConfiguration() } ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-sone-id") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt index e622554..c6274a2 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt @@ -14,8 +14,8 @@ class UntrustAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("untrustSon override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] - ?.let(webInterface.core::getSone) - ?.also { webInterface.core.untrustSone(currentSone, it) } + ?.let(core::getSone) + ?.also { core.untrustSone(currentSone, it) } ?.let { createSuccessJsonObject() } ?: createErrorJsonObject("invalid-sone-id") -- 2.7.4