From c4b8d932cea4585dfff9def67646f6a94c91af74 Mon Sep 17 00:00:00 2001 From: Akihiro Urushiara Date: Thu, 4 Jan 2024 02:27:13 +0900 Subject: [PATCH] checking graph apis. --- .../api/entity/bsky/graph/GraphGetBlocksResponse.kt | 2 +- .../api/entity/bsky/graph/GraphGetFollowersResponse.kt | 9 ++++----- .../api/entity/bsky/graph/GraphGetFollowsResponse.kt | 4 ++-- .../kbsky/api/entity/bsky/graph/GraphGetMutesResponse.kt | 2 +- .../work/socialhub/kbsky/internal/bsky/_GraphResource.kt | 8 ++++---- .../work/socialhub/kbsky/bsky/graph/GetBlocksTest.kt | 2 +- .../work/socialhub/kbsky/bsky/graph/GetFollowersTest.kt | 7 ++++--- .../work/socialhub/kbsky/bsky/graph/GetFollowsTest.kt | 4 ++-- .../work/socialhub/kbsky/bsky/graph/GetMutesTest.kt | 2 +- .../kotlin/work/socialhub/kbsky/bsky/graph/MuteTest.kt | 8 +++++--- 10 files changed, 25 insertions(+), 23 deletions(-) diff --git a/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetBlocksResponse.kt b/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetBlocksResponse.kt index 964015e..3ffa1e1 100644 --- a/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetBlocksResponse.kt +++ b/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetBlocksResponse.kt @@ -6,5 +6,5 @@ import work.socialhub.kbsky.model.bsky.actor.ActorDefsProfileView @Serializable class GraphGetBlocksResponse { var cursor: String? = null - var blocks: List? = null + lateinit var blocks: List } diff --git a/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetFollowersResponse.kt b/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetFollowersResponse.kt index 8162dd5..d021208 100644 --- a/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetFollowersResponse.kt +++ b/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetFollowersResponse.kt @@ -1,12 +1,11 @@ package work.socialhub.kbsky.api.entity.bsky.graph +import kotlinx.serialization.Serializable import work.socialhub.kbsky.model.bsky.actor.ActorDefsProfileView +@Serializable class GraphGetFollowersResponse { - // region - var subject: ActorDefsProfileView? = null var cursor: String? = null - - // endregion - var followers: List? = null + lateinit var subject: ActorDefsProfileView + lateinit var followers: List } diff --git a/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetFollowsResponse.kt b/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetFollowsResponse.kt index 60c614a..5e5d5fb 100644 --- a/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetFollowsResponse.kt +++ b/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetFollowsResponse.kt @@ -5,7 +5,7 @@ import work.socialhub.kbsky.model.bsky.actor.ActorDefsProfileView @Serializable class GraphGetFollowsResponse { - var subject: ActorDefsProfileView? = null var cursor: String? = null - var follows: List? = null + lateinit var subject: ActorDefsProfileView + lateinit var follows: List } diff --git a/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetMutesResponse.kt b/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetMutesResponse.kt index 8779024..c112056 100644 --- a/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetMutesResponse.kt +++ b/core/src/commonMain/kotlin/work/socialhub/kbsky/api/entity/bsky/graph/GraphGetMutesResponse.kt @@ -6,5 +6,5 @@ import work.socialhub.kbsky.model.bsky.actor.ActorDefsProfileView @Serializable class GraphGetMutesResponse { var cursor: String? = null - var mutes: List? = null + lateinit var mutes: List } diff --git a/core/src/commonMain/kotlin/work/socialhub/kbsky/internal/bsky/_GraphResource.kt b/core/src/commonMain/kotlin/work/socialhub/kbsky/internal/bsky/_GraphResource.kt index ac9c530..c2e01d2 100644 --- a/core/src/commonMain/kotlin/work/socialhub/kbsky/internal/bsky/_GraphResource.kt +++ b/core/src/commonMain/kotlin/work/socialhub/kbsky/internal/bsky/_GraphResource.kt @@ -130,8 +130,8 @@ class _GraphResource( .url(xrpc(uri, GraphMuteActor)) .header("Authorization", request.bearerToken) .accept(MediaType.JSON) - .queries(request.toMap()) - .get() + .json(request.toMappedJson()) + .post() } } } @@ -146,8 +146,8 @@ class _GraphResource( .url(xrpc(uri, GraphUnmuteActor)) .header("Authorization", request.bearerToken) .accept(MediaType.JSON) - .queries(request.toMap()) - .get() + .json(request.toMappedJson()) + .post() } } } diff --git a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetBlocksTest.kt b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetBlocksTest.kt index 18a2164..eb1bf3b 100644 --- a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetBlocksTest.kt +++ b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetBlocksTest.kt @@ -17,7 +17,7 @@ class GetBlocksTest : AbstractTest() { GraphGetBlocksRequest(accessJwt) ) - checkNotNull(response.data.blocks) + response.data.blocks .forEach { print(it) } } } diff --git a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetFollowersTest.kt b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetFollowersTest.kt index 4588e12..ed51381 100644 --- a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetFollowersTest.kt +++ b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetFollowersTest.kt @@ -4,6 +4,7 @@ import work.socialhub.kbsky.AbstractTest import work.socialhub.kbsky.BlueskyFactory import work.socialhub.kbsky.api.entity.bsky.graph.GraphGetFollowersRequest import work.socialhub.kbsky.domain.Service +import work.socialhub.kbsky.domain.Service.BSKY_SOCIAL import kotlin.test.Test class GetFollowersTest : AbstractTest() { @@ -11,15 +12,15 @@ class GetFollowersTest : AbstractTest() { @Test fun testGetFollowers() { val response = BlueskyFactory - .instance(Service.BSKY_SOCIAL.uri) + .instance(BSKY_SOCIAL.uri) .graph() .getFollowers( GraphGetFollowersRequest(accessJwt).also { - it.actor = "uakihir0.bsky.social" + it.actor = "uakihir0.com" } ) - checkNotNull(response.data.followers) + response.data.followers .forEach { print(it) } } } diff --git a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetFollowsTest.kt b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetFollowsTest.kt index 6fd6413..5bbea55 100644 --- a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetFollowsTest.kt +++ b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetFollowsTest.kt @@ -15,11 +15,11 @@ class GetFollowsTest : AbstractTest() { .graph() .getFollows( GraphGetFollowsRequest(accessJwt).also { - it.actor = "uakihir0.bsky.social" + it.actor = "uakihir0.com" } ) - checkNotNull(response.data.follows) + response.data.follows .forEach { print(it) } } } diff --git a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetMutesTest.kt b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetMutesTest.kt index 4c0802a..31c74d6 100644 --- a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetMutesTest.kt +++ b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/GetMutesTest.kt @@ -17,7 +17,7 @@ class GetMutesTest : AbstractTest() { GraphGetMutesRequest(accessJwt) ) - checkNotNull(response.data.mutes) + response.data.mutes .forEach(this::print) } } diff --git a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/MuteTest.kt b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/MuteTest.kt index 9e316f6..8a12539 100644 --- a/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/MuteTest.kt +++ b/core/src/jvmTest/kotlin/work/socialhub/kbsky/bsky/graph/MuteTest.kt @@ -12,9 +12,10 @@ class MuteTest : AbstractTest() { fun testMute() { BlueskyFactory .instance(BSKY_SOCIAL.uri) - .graph().muteActor( + .graph() + .muteActor( GraphMuteActorRequest(accessJwt).also { - it.actor = "uakihir0.bsky.social" + it.actor = "bsky.app" } ) } @@ -23,7 +24,8 @@ class MuteTest : AbstractTest() { fun testMuteByDID() { BlueskyFactory .instance(BSKY_SOCIAL.uri) - .graph().muteActor( + .graph() + .muteActor( GraphMuteActorRequest(accessJwt).also { it.actor = "did:plc:oc6vwdlmk2kqyida5i74d3p5" }