mirror of https://github.com/usbharu/Hideout.git
feat: remove Spring WebFlux
This commit is contained in:
parent
a32cfe348e
commit
2f4cf69334
|
@ -55,11 +55,7 @@ tasks.create<GenerateTask>("openApiGenerateMastodonCompatibleApi", GenerateTask:
|
||||||
modelPackage.set("dev.usbharu.hideout.domain.mastodon.model.generated")
|
modelPackage.set("dev.usbharu.hideout.domain.mastodon.model.generated")
|
||||||
configOptions.put("interfaceOnly", "true")
|
configOptions.put("interfaceOnly", "true")
|
||||||
configOptions.put("useSpringBoot3", "true")
|
configOptions.put("useSpringBoot3", "true")
|
||||||
configOptions.put("reactive", "true")
|
|
||||||
additionalProperties.put("useTags", "true")
|
additionalProperties.put("useTags", "true")
|
||||||
|
|
||||||
// importMappings.putAll(mapOf("ReactionResponse" to "ReactionResponse"))
|
|
||||||
// typeMappings.putAll(mapOf("ReactionResponse" to "ReactionResponse"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -108,8 +104,6 @@ dependencies {
|
||||||
implementation("org.springframework.data:spring-data-commons")
|
implementation("org.springframework.data:spring-data-commons")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-jdbc")
|
implementation("org.springframework.boot:spring-boot-starter-jdbc")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
|
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-webflux")
|
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
|
|
||||||
testImplementation("org.springframework.boot:spring-boot-test-autoconfigure")
|
testImplementation("org.springframework.boot:spring-boot-test-autoconfigure")
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||||
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
||||||
|
|
|
@ -3,6 +3,7 @@ package dev.usbharu.hideout.controller.mastodon
|
||||||
import dev.usbharu.hideout.controller.mastodon.generated.AccountApi
|
import dev.usbharu.hideout.controller.mastodon.generated.AccountApi
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.CredentialAccount
|
import dev.usbharu.hideout.domain.mastodon.model.generated.CredentialAccount
|
||||||
import dev.usbharu.hideout.service.api.mastodon.AccountApiService
|
import dev.usbharu.hideout.service.api.mastodon.AccountApiService
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.springframework.http.HttpStatus
|
import org.springframework.http.HttpStatus
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.security.core.context.SecurityContextHolder
|
import org.springframework.security.core.context.SecurityContextHolder
|
||||||
|
@ -11,10 +12,10 @@ import org.springframework.stereotype.Controller
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
class MastodonAccountApiController(private val accountApiService: AccountApiService) : AccountApi {
|
class MastodonAccountApiController(private val accountApiService: AccountApiService) : AccountApi {
|
||||||
override suspend fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity<CredentialAccount> {
|
override fun apiV1AccountsVerifyCredentialsGet(): ResponseEntity<CredentialAccount> = runBlocking {
|
||||||
val principal = SecurityContextHolder.getContext().getAuthentication().principal as Jwt
|
val principal = SecurityContextHolder.getContext().getAuthentication().principal as Jwt
|
||||||
|
|
||||||
return ResponseEntity(
|
ResponseEntity(
|
||||||
accountApiService.verifyCredentials(principal.getClaim<String>("uid").toLong()),
|
accountApiService.verifyCredentials(principal.getClaim<String>("uid").toLong()),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import dev.usbharu.hideout.controller.mastodon.generated.AppApi
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.Application
|
import dev.usbharu.hideout.domain.mastodon.model.generated.Application
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.AppsRequest
|
import dev.usbharu.hideout.domain.mastodon.model.generated.AppsRequest
|
||||||
import dev.usbharu.hideout.service.api.mastodon.AppApiService
|
import dev.usbharu.hideout.service.api.mastodon.AppApiService
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.springframework.http.HttpStatus
|
import org.springframework.http.HttpStatus
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.stereotype.Controller
|
import org.springframework.stereotype.Controller
|
||||||
|
@ -13,9 +14,9 @@ import org.springframework.web.bind.annotation.RequestParam
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
class MastodonAppsApiController(private val appApiService: AppApiService) : AppApi {
|
class MastodonAppsApiController(private val appApiService: AppApiService) : AppApi {
|
||||||
override suspend fun apiV1AppsPost(appsRequest: AppsRequest): ResponseEntity<Application> {
|
override fun apiV1AppsPost(appsRequest: AppsRequest): ResponseEntity<Application> = runBlocking {
|
||||||
println(appsRequest)
|
println(appsRequest)
|
||||||
return ResponseEntity(
|
ResponseEntity(
|
||||||
appApiService.createApp(appsRequest),
|
appApiService.createApp(appsRequest),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
)
|
)
|
||||||
|
@ -27,10 +28,10 @@ class MastodonAppsApiController(private val appApiService: AppApiService) : AppA
|
||||||
produces = ["application/json"],
|
produces = ["application/json"],
|
||||||
consumes = ["application/x-www-form-urlencoded"]
|
consumes = ["application/x-www-form-urlencoded"]
|
||||||
)
|
)
|
||||||
suspend fun apiV1AppsPost(@RequestParam map: Map<String, String>): ResponseEntity<Application> {
|
fun apiV1AppsPost(@RequestParam map: Map<String, String>): ResponseEntity<Application> = runBlocking {
|
||||||
val appsRequest =
|
val appsRequest =
|
||||||
AppsRequest(map.getValue("client_name"), map.getValue("redirect_uris"), map["scopes"], map["website"])
|
AppsRequest(map.getValue("client_name"), map.getValue("redirect_uris"), map["scopes"], map["website"])
|
||||||
return ResponseEntity(
|
ResponseEntity(
|
||||||
appApiService.createApp(appsRequest),
|
appApiService.createApp(appsRequest),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,13 +3,14 @@ package dev.usbharu.hideout.controller.mastodon
|
||||||
import dev.usbharu.hideout.controller.mastodon.generated.InstanceApi
|
import dev.usbharu.hideout.controller.mastodon.generated.InstanceApi
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.V1Instance
|
import dev.usbharu.hideout.domain.mastodon.model.generated.V1Instance
|
||||||
import dev.usbharu.hideout.service.api.mastodon.InstanceApiService
|
import dev.usbharu.hideout.service.api.mastodon.InstanceApiService
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.springframework.http.HttpStatus
|
import org.springframework.http.HttpStatus
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.stereotype.Controller
|
import org.springframework.stereotype.Controller
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
class MastodonInstanceApiController(private val instanceApiService: InstanceApiService) : InstanceApi {
|
class MastodonInstanceApiController(private val instanceApiService: InstanceApiService) : InstanceApi {
|
||||||
override suspend fun apiV1InstanceGet(): ResponseEntity<V1Instance> {
|
override fun apiV1InstanceGet(): ResponseEntity<V1Instance> = runBlocking {
|
||||||
return ResponseEntity(instanceApiService.v1Instance(), HttpStatus.OK)
|
ResponseEntity(instanceApiService.v1Instance(), HttpStatus.OK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import dev.usbharu.hideout.domain.mastodon.model.generated.Status
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.StatusesRequest
|
import dev.usbharu.hideout.domain.mastodon.model.generated.StatusesRequest
|
||||||
import dev.usbharu.hideout.domain.model.UserDetailsImpl
|
import dev.usbharu.hideout.domain.model.UserDetailsImpl
|
||||||
import dev.usbharu.hideout.service.api.mastodon.StatusesApiService
|
import dev.usbharu.hideout.service.api.mastodon.StatusesApiService
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.springframework.http.HttpStatus
|
import org.springframework.http.HttpStatus
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.security.core.context.SecurityContextHolder
|
import org.springframework.security.core.context.SecurityContextHolder
|
||||||
|
@ -12,9 +13,9 @@ import org.springframework.stereotype.Controller
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
class MastodonStatusesApiContoller(private val statusesApiService: StatusesApiService) : StatusApi {
|
class MastodonStatusesApiContoller(private val statusesApiService: StatusesApiService) : StatusApi {
|
||||||
override suspend fun apiV1StatusesPost(statusesRequest: StatusesRequest): ResponseEntity<Status> {
|
override fun apiV1StatusesPost(statusesRequest: StatusesRequest): ResponseEntity<Status> = runBlocking {
|
||||||
val principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal()
|
val principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal()
|
||||||
require(principal is UserDetailsImpl)
|
require(principal is UserDetailsImpl)
|
||||||
return ResponseEntity(statusesApiService.postStatus(statusesRequest, principal), HttpStatus.OK)
|
ResponseEntity(statusesApiService.postStatus(statusesRequest, principal), HttpStatus.OK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue