mirror of https://github.com/usbharu/Hideout.git
feat: レスポンスのクラスを作成
This commit is contained in:
parent
469b886caf
commit
ab01b61f55
|
@ -0,0 +1,5 @@
|
|||
package dev.usbharu.hideout.domain.model
|
||||
|
||||
import io.ktor.http.*
|
||||
|
||||
data class ActivityPubResponse(val httpStatusCode: HttpStatusCode, val message:String)
|
|
@ -20,8 +20,12 @@ fun Routing.inbox(httpSignatureVerifyService: HttpSignatureVerifyService,activit
|
|||
}
|
||||
val json = call.receiveText()
|
||||
val activityTypes = activityPubService.parseActivity(json)
|
||||
activityPubService.processActivity(json,activityTypes)
|
||||
call.respond(HttpStatusCode.NotImplemented)
|
||||
val response = activityPubService.processActivity(json, activityTypes)
|
||||
return@post if (response != null) {
|
||||
call.respond(response.httpStatusCode, response.message)
|
||||
}else {
|
||||
call.respond(HttpStatusCode.InternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
route("/users/{name}/inbox"){
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package dev.usbharu.hideout.service.activitypub
|
||||
|
||||
import dev.usbharu.hideout.domain.model.ActivityPubResponse
|
||||
|
||||
interface ActivityPubService {
|
||||
fun parseActivity(json:String): ActivityType
|
||||
|
||||
fun processActivity(json:String, type: ActivityType)
|
||||
fun processActivity(json:String, type: ActivityType):ActivityPubResponse?
|
||||
}
|
||||
|
||||
enum class ActivityType {
|
||||
|
|
|
@ -2,6 +2,7 @@ package dev.usbharu.hideout.service.activitypub
|
|||
|
||||
import com.fasterxml.jackson.databind.JsonNode
|
||||
import dev.usbharu.hideout.config.Config
|
||||
import dev.usbharu.hideout.domain.model.ActivityPubResponse
|
||||
import dev.usbharu.hideout.exception.JsonParseException
|
||||
|
||||
class ActivityPubServiceImpl : ActivityPubService {
|
||||
|
@ -19,7 +20,7 @@ class ActivityPubServiceImpl : ActivityPubService {
|
|||
return ActivityType.values().first { it.name.equals(type.asText(), true) }
|
||||
}
|
||||
|
||||
override fun processActivity(json: String, type: ActivityType) {
|
||||
override fun processActivity(json: String, type: ActivityType): ActivityPubResponse? {
|
||||
when (type) {
|
||||
ActivityType.Accept -> TODO()
|
||||
ActivityType.Add -> TODO()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.usbharu.hideout.routing.activitypub
|
||||
|
||||
import dev.usbharu.hideout.domain.model.ActivityPubResponse
|
||||
import dev.usbharu.hideout.plugins.configureRouting
|
||||
import dev.usbharu.hideout.service.activitypub.ActivityPubService
|
||||
import dev.usbharu.hideout.service.activitypub.ActivityType
|
||||
|
@ -30,7 +31,7 @@ class UsersAPTest {
|
|||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun processActivity(json: String, type: ActivityType) {
|
||||
override fun processActivity(json: String, type: ActivityType): ActivityPubResponse? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue