feat: usersのinboxにも対応

This commit is contained in:
usbharu 2023-04-10 00:53:42 +09:00
parent 9fe24927a0
commit a5039af630
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
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)
}
}
}