mirror of https://github.com/usbharu/Hideout.git
Compare commits
3 Commits
16c43472f4
...
ca0f9890c2
| Author | SHA1 | Date |
|---|---|---|
|
|
ca0f9890c2 | |
|
|
0cd4546256 | |
|
|
801be7fe38 |
|
|
@ -144,6 +144,9 @@ dependencies {
|
|||
implementation("io.swagger.core.v3:swagger-models:2.2.6")
|
||||
implementation("org.jetbrains.exposed:exposed-java-time:$exposed_version")
|
||||
implementation("org.jetbrains.exposed:spring-transaction:$exposed_version")
|
||||
implementation("org.springframework.data:spring-data-commons")
|
||||
implementation("org.springframework.boot:spring-boot-starter-jdbc")
|
||||
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
|
||||
|
||||
implementation("io.ktor:ktor-client-logging-jvm:$ktor_version")
|
||||
implementation("io.ktor:ktor-server-host-common-jvm:$ktor_version")
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.koin.ksp.generated.module
|
|||
import org.koin.ktor.ext.inject
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun main(args: Array<String>): Unit = io.ktor.server.cio.EngineMain.main(args)
|
||||
|
||||
val Application.property: Application.(propertyName: String) -> String
|
||||
|
|
@ -52,6 +53,7 @@ val Application.propertyOrNull: Application.(propertyName: String) -> String?
|
|||
}
|
||||
|
||||
// application.conf references the main function. This annotation prevents the IDE from marking it as unused.
|
||||
@Deprecated("Ktor is deprecated")
|
||||
@Suppress("unused", "LongMethod")
|
||||
fun Application.parent() {
|
||||
Config.configData = ConfigData(
|
||||
|
|
@ -136,6 +138,7 @@ fun Application.parent() {
|
|||
)
|
||||
}
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
@Suppress("unused")
|
||||
fun Application.worker() {
|
||||
val kJob = kjob(ExposedKJob) {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ package dev.usbharu.hideout.config
|
|||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
|
||||
@Deprecated("Config is deprecated")
|
||||
object Config {
|
||||
var configData: ConfigData = ConfigData()
|
||||
}
|
||||
|
||||
@Deprecated("Config is deprecated")
|
||||
data class ConfigData(
|
||||
val url: String = "",
|
||||
val domain: String = url.substringAfter("://").substringBeforeLast(":"),
|
||||
|
|
@ -14,12 +16,14 @@ data class ConfigData(
|
|||
val characterLimit: CharacterLimit = CharacterLimit()
|
||||
)
|
||||
|
||||
@Deprecated("Config is deprecated")
|
||||
data class CharacterLimit(
|
||||
val general: General = General.of(),
|
||||
val post: Post = Post(),
|
||||
val account: Account = Account(),
|
||||
val instance: Instance = Instance()
|
||||
) {
|
||||
@Deprecated("Config is deprecated")
|
||||
data class General private constructor(
|
||||
val url: Int,
|
||||
val domain: Int,
|
||||
|
|
@ -39,17 +43,20 @@ data class CharacterLimit(
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated("Config is deprecated")
|
||||
data class Post(
|
||||
val text: Int = 3000,
|
||||
val overview: Int = 3000
|
||||
)
|
||||
|
||||
@Deprecated("Config is deprecated")
|
||||
data class Account(
|
||||
val id: Int = 300,
|
||||
val name: Int = 300,
|
||||
val description: Int = 10000
|
||||
)
|
||||
|
||||
@Deprecated("Config is deprecated")
|
||||
data class Instance(
|
||||
val name: Int = 600,
|
||||
val description: Int = 10000
|
||||
|
|
|
|||
|
|
@ -98,7 +98,11 @@ class SecurityConfig {
|
|||
|
||||
@Bean
|
||||
fun authorizationServerSettings(): AuthorizationServerSettings {
|
||||
return AuthorizationServerSettings.builder().build()
|
||||
return AuthorizationServerSettings.builder()
|
||||
.authorizationEndpoint("/oauth/authorize")
|
||||
.tokenEndpoint("/oauth/token")
|
||||
.tokenRevocationEndpoint("/oauth/revoke")
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package dev.usbharu.hideout.config
|
||||
|
||||
import org.jetbrains.exposed.spring.SpringTransactionManager
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.transaction.PlatformTransactionManager
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement
|
||||
import org.springframework.transaction.annotation.TransactionManagementConfigurer
|
||||
import javax.sql.DataSource
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
class SpringTransactionConfig(val datasource: DataSource) : TransactionManagementConfigurer {
|
||||
@Bean
|
||||
override fun annotationDrivenTransactionManager(): PlatformTransactionManager {
|
||||
return SpringTransactionManager(datasource)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package dev.usbharu.hideout.controller
|
||||
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RequestMethod
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
interface InboxController {
|
||||
@RequestMapping(
|
||||
"/inbox",
|
||||
"/users/{username}/inbox",
|
||||
produces = ["application/activity+json", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""],
|
||||
method = [RequestMethod.GET, RequestMethod.POST]
|
||||
)
|
||||
suspend fun inbox(@RequestBody string: String): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.ACCEPTED)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package dev.usbharu.hideout.controller
|
||||
|
||||
import dev.usbharu.hideout.service.ap.APService
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
class InboxControllerImpl(private val apService: APService) : InboxController {
|
||||
override suspend fun inbox(string: String): ResponseEntity<Unit> {
|
||||
val parseActivity = apService.parseActivity(string)
|
||||
apService.processActivity(string, parseActivity)
|
||||
return ResponseEntity(HttpStatus.ACCEPTED)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package dev.usbharu.hideout.controller
|
||||
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RequestMethod
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
interface OutboxController {
|
||||
@RequestMapping("/outbox", "/users/{username}/outbox", method = [RequestMethod.POST, RequestMethod.GET])
|
||||
fun outbox(@RequestBody string: String): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.ACCEPTED)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package dev.usbharu.hideout.controller
|
||||
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
class OutboxControllerImpl : OutboxController {
|
||||
override fun outbox(@RequestBody string: String): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package dev.usbharu.hideout.controller
|
||||
|
||||
import dev.usbharu.hideout.domain.model.ap.Person
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
interface UserAPController {
|
||||
@GetMapping("/users/{username}")
|
||||
suspend fun userAp(@PathVariable("username") username: String): ResponseEntity<Person>
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package dev.usbharu.hideout.controller
|
||||
|
||||
import dev.usbharu.hideout.domain.model.ap.Person
|
||||
import dev.usbharu.hideout.service.ap.APUserService
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
class UserAPControllerImpl(private val apUserService: APUserService) : UserAPController {
|
||||
override suspend fun userAp(username: String): ResponseEntity<Person> {
|
||||
val person = apUserService.getPersonByName(username)
|
||||
return ResponseEntity(person, HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import io.ktor.http.*
|
|||
import io.ktor.server.application.*
|
||||
import io.ktor.server.plugins.compression.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Application.configureCompression() {
|
||||
install(Compression) {
|
||||
gzip {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import io.ktor.server.application.*
|
|||
import io.ktor.server.plugins.defaultheaders.*
|
||||
import io.ktor.server.plugins.forwardedheaders.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Application.configureHTTP() {
|
||||
// install(CORS) {
|
||||
// allowMethod(HttpMethod.Options)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import org.koin.core.module.Module
|
|||
import org.koin.ktor.plugin.Koin
|
||||
import org.koin.logger.slf4jLogger
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Application.configureKoin(vararg module: Module) {
|
||||
install(Koin) {
|
||||
slf4jLogger()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import io.ktor.server.application.*
|
|||
import io.ktor.server.plugins.callloging.*
|
||||
import org.slf4j.event.Level
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Application.configureMonitoring() {
|
||||
install(CallLogging) {
|
||||
level = Level.INFO
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import io.ktor.server.application.*
|
|||
import io.ktor.server.plugins.autohead.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
@Suppress("LongParameterList")
|
||||
fun Application.configureRouting(
|
||||
httpSignatureVerifyService: HttpSignatureVerifyService,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import io.ktor.server.routing.*
|
|||
|
||||
const val TOKEN_AUTH = "jwt-auth"
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
@Suppress("MagicNumber")
|
||||
fun Application.configureSecurity(
|
||||
jwkProvider: JwkProvider,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import io.ktor.serialization.jackson.*
|
|||
import io.ktor.server.application.*
|
||||
import io.ktor.server.plugins.contentnegotiation.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Application.configureSerialization() {
|
||||
install(ContentNegotiation) {
|
||||
jackson {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import io.ktor.server.http.content.*
|
|||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Application.configureStaticRouting() {
|
||||
routing {
|
||||
get("/") {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import io.ktor.server.application.*
|
|||
import io.ktor.server.plugins.statuspages.*
|
||||
import io.ktor.server.response.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Application.configureStatusPages() {
|
||||
install(StatusPages) {
|
||||
exception<IllegalArgumentException> { call, cause ->
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.springframework.security.oauth2.server.authorization.settings.Configu
|
|||
import org.springframework.security.oauth2.server.authorization.settings.OAuth2TokenFormat
|
||||
import org.springframework.security.oauth2.server.authorization.settings.TokenSettings
|
||||
import org.springframework.stereotype.Repository
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import java.time.Instant
|
||||
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient as SpringRegisteredClient
|
||||
|
||||
|
|
@ -75,6 +76,7 @@ class RegisteredClientRepositoryImpl(private val database: Database) : Registere
|
|||
}.singleOrNull()?.toRegisteredClient()
|
||||
}
|
||||
|
||||
@Transactional
|
||||
override fun findByClientId(clientId: String?): SpringRegisteredClient? {
|
||||
if (clientId == null) {
|
||||
return null
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import io.ktor.server.request.*
|
|||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Application.register(userApiService: UserApiService) {
|
||||
routing {
|
||||
get("/register") {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import io.ktor.server.request.*
|
|||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Routing.inbox(
|
||||
httpSignatureVerifyService: HttpSignatureVerifyService,
|
||||
apService: dev.usbharu.hideout.service.ap.APService
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import io.ktor.server.application.*
|
|||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Routing.outbox() {
|
||||
route("/outbox") {
|
||||
get {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import io.ktor.server.request.*
|
|||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Routing.usersAP(
|
||||
apUserService: APUserService,
|
||||
userQueryService: UserQueryService,
|
||||
|
|
@ -50,6 +51,7 @@ fun Routing.usersAP(
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
class ContentTypeRouteSelector(private vararg val contentType: ContentType) : RouteSelector() {
|
||||
override fun evaluate(context: RoutingResolveContext, segmentIndex: Int): RouteSelectorEvaluation {
|
||||
context.call.application.log.debug("Accept: ${context.call.request.accept()}")
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import io.ktor.server.request.*
|
|||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Route.auth(userAuthApiService: UserAuthApiService) {
|
||||
post("/login") {
|
||||
val loginUser = call.receive<UserLogin>()
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import io.ktor.server.request.*
|
|||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
@Suppress("LongMethod")
|
||||
fun Route.posts(postApiService: PostApiService) {
|
||||
route("/posts") {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import io.ktor.server.request.*
|
|||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
@Suppress("LongMethod", "CognitiveComplexMethod")
|
||||
fun Route.users(userService: UserService, userApiService: UserApiService) {
|
||||
route("/users") {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import io.ktor.server.application.*
|
|||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
@Deprecated("Ktor is deprecated")
|
||||
fun Routing.webfinger(webFingerApiService: WebFingerApiService) {
|
||||
route("/.well-known/webfinger") {
|
||||
get {
|
||||
|
|
|
|||
|
|
@ -4,3 +4,9 @@ hideout:
|
|||
driver: "org.h2.Driver"
|
||||
user: ""
|
||||
password: ""
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: org.h2.Driver
|
||||
url: "jdbc:h2:./test;MODE=POSTGRESQL"
|
||||
username: ""
|
||||
password: ""
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: Hideout Mastodon Compatible API
|
||||
description: Hideout Mastodon Compatible API
|
||||
version: 1.0.0
|
||||
servers:
|
||||
- url: 'https://test-hideout.usbharu.dev'
|
||||
paths:
|
||||
|
||||
components:
|
||||
schemas:
|
||||
Account:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
username:
|
||||
type: string
|
||||
acct:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
Loading…
Reference in New Issue