mirror of https://github.com/usbharu/Hideout.git
refactor: 不要なクラス、インポート等を削除
This commit is contained in:
parent
ee46d05226
commit
9558a53df1
|
@ -1,6 +1,5 @@
|
||||||
package dev.usbharu.hideout.routing.activitypub
|
package dev.usbharu.hideout.routing.activitypub
|
||||||
|
|
||||||
import dev.usbharu.hideout.config.Config
|
|
||||||
import dev.usbharu.hideout.exception.ParameterNotExistException
|
import dev.usbharu.hideout.exception.ParameterNotExistException
|
||||||
import dev.usbharu.hideout.plugins.respondAp
|
import dev.usbharu.hideout.plugins.respondAp
|
||||||
import dev.usbharu.hideout.service.activitypub.ActivityPubUserService
|
import dev.usbharu.hideout.service.activitypub.ActivityPubUserService
|
||||||
|
@ -9,7 +8,6 @@ import dev.usbharu.hideout.util.HttpUtil.JsonLd
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.request.*
|
import io.ktor.server.request.*
|
||||||
import io.ktor.server.response.*
|
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
|
|
||||||
fun Routing.usersAP(activityPubUserService: ActivityPubUserService) {
|
fun Routing.usersAP(activityPubUserService: ActivityPubUserService) {
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
package dev.usbharu.hideout.routing
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import dev.usbharu.hideout.ap.Follow
|
|
||||||
import dev.usbharu.hideout.config.Config
|
|
||||||
import dev.usbharu.hideout.service.impl.ActivityPubService
|
|
||||||
import dev.usbharu.hideout.service.impl.ActivityPubUserService
|
|
||||||
import dev.usbharu.hideout.util.HttpUtil
|
|
||||||
import io.ktor.http.*
|
|
||||||
import io.ktor.server.application.*
|
|
||||||
import io.ktor.server.request.*
|
|
||||||
import io.ktor.server.response.*
|
|
||||||
import io.ktor.server.routing.*
|
|
||||||
|
|
||||||
fun Application.userActivityPubRouting(activityPubService: ActivityPubService, activityPubUserService: ActivityPubUserService) {
|
|
||||||
routing {
|
|
||||||
route("/users/{name}") {
|
|
||||||
route("/inbox") {
|
|
||||||
get {
|
|
||||||
call.respond(HttpStatusCode.MethodNotAllowed)
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
if (!HttpUtil.isContentTypeOfActivityPub(call.request.contentType())) {
|
|
||||||
return@post call.respond(HttpStatusCode.BadRequest)
|
|
||||||
}
|
|
||||||
val bodyText = call.receiveText()
|
|
||||||
println(bodyText)
|
|
||||||
when (activityPubService.switchApType(bodyText)) {
|
|
||||||
ActivityPubService.ActivityType.Follow -> {
|
|
||||||
val readValue = Config.configData.objectMapper.readValue<Follow>(bodyText)
|
|
||||||
activityPubUserService.receiveFollow(readValue)
|
|
||||||
return@post call.respond(HttpStatusCode.Accepted)
|
|
||||||
}
|
|
||||||
|
|
||||||
ActivityPubService.ActivityType.Undo -> {
|
|
||||||
return@post call.respond(HttpStatusCode.Accepted)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
route("/outbox") {
|
|
||||||
get {
|
|
||||||
call.respond(HttpStatusCode.MethodNotAllowed)
|
|
||||||
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
|
|
||||||
call.respond(HttpStatusCode.MethodNotAllowed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package dev.usbharu.hideout.routing
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
|
|
||||||
class UserRoutingKtTest {
|
|
||||||
@Test
|
|
||||||
fun userIconTest() {
|
|
||||||
println(String.Companion::class.java.classLoader)
|
|
||||||
println(String::class.java.classLoader)
|
|
||||||
println(String.javaClass.classLoader.getResourceAsStream("icon.png")?.readAllBytes())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package dev.usbharu.hideout.routing.activitypub
|
||||||
|
class InboxRoutingKtTest {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue