From a5039af6302e389741e7e88655b5f2a3b695cf11 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 10 Apr 2023 00:53:42 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20users=E3=81=AEinbox=E3=81=AB=E3=82=82?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hideout/routing/activitypub/InboxRouting.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 a1e3b6a9..21e15b5f 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/activitypub/InboxRouting.kt @@ -41,7 +41,19 @@ fun Routing.inbox( call.respond(HttpStatusCode.NotImplemented) } post { - call.respond(HttpStatusCode.MethodNotAllowed) + if (httpSignatureVerifyService.verify(call.request.headers).not()) { + throw HttpSignatureVerifyException() + } + val json = call.receiveText() + val activityTypes = activityPubService.parseActivity(json) + 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 ActivityPubStringResponse -> call.respond(response.httpStatusCode, response.message) + null -> call.respond(HttpStatusCode.NotImplemented) + } } }