From a34851dfdadbeb7dfe59b888b6775d598417b74d Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 10 Apr 2023 15:11:26 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20Inbox=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routing/activitypub/InboxRouting.kt | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt index 92753f36..9ab1d098 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt @@ -30,9 +30,13 @@ fun Routing.inbox( call.application.log.debug("ActivityTypes: ${activityTypes.name}") val response = activityPubService.processActivity(json, activityTypes) when (response) { - is ActivityPubObjectResponse -> call.respond(response.httpStatusCode, Config.configData.objectMapper.writeValueAsString(response.message.apply { context = - listOf("https://www.w3.org/ns/activitystreams") - })) + is ActivityPubObjectResponse -> call.respond( + response.httpStatusCode, + Config.configData.objectMapper.writeValueAsString(response.message.apply { + context = + listOf("https://www.w3.org/ns/activitystreams") + }) + ) is ActivityPubStringResponse -> call.respond(response.httpStatusCode, response.message) null -> call.respond(HttpStatusCode.NotImplemented) } @@ -47,13 +51,18 @@ fun Routing.inbox( throw HttpSignatureVerifyException() } val json = call.receiveText() + call.application.log.trace("Received: $json") val activityTypes = activityPubService.parseActivity(json) - println(activityTypes) + call.application.log.debug("ActivityTypes: ${activityTypes.name}") val response = activityPubService.processActivity(json, activityTypes) when (response) { - is ActivityPubObjectResponse -> call.respond(response.httpStatusCode, Config.configData.objectMapper.writeValueAsString(response.message.apply { context = - listOf("https://www.w3.org/ns/activitystreams") - })) + is ActivityPubObjectResponse -> call.respond( + response.httpStatusCode, + Config.configData.objectMapper.writeValueAsString(response.message.apply { + context = + listOf("https://www.w3.org/ns/activitystreams") + }) + ) is ActivityPubStringResponse -> call.respond(response.httpStatusCode, response.message) null -> call.respond(HttpStatusCode.NotImplemented) }