feat: usersのinboxにも対応

This commit is contained in:
usbharu 2023-04-10 00:53:42 +09:00
parent c719716860
commit c20b5ce064
1 changed files with 13 additions and 1 deletions

View File

@ -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)
}
}
}